السلام عليكم
كتبت هذا الكود ولا توجد به اي اخطاء
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JDBCResultSetExample {
Connection connection = null;
public JDBCResultSetExample() {
try {
// Loading the driver
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException e) {
System.out.println(e.toString());
}
}
public Connection createConnection() {
Connection con = null;
if (connection != null) {
System.out.println("Cant create a connection");
} else {
try {
// Crating a Connection to the Student database
con = DriverManager.getConnection(
"jdbc:postgresql://localhost:5432/Database2011", "postgres",
"dalia123");
System.out.println("Connection created Successfully");
} catch (SQLException e) {
System.out.println(e.toString());
}
}
return con;
}
public static void main(String[] args) throws SQLException {
JDBCResultSetExample resultSetExample = new JDBCResultSetExample();
Connection connection = resultSetExample.createConnection();
try {
// creating a statement object
Statement statement = connection.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String query = "SELECT descrip FROM prod";
// executing a query string and storing it into the resultSet object
ResultSet resultSet = statement.executeQuery(query);
System.out.println("Before Updating....................\n");
while (resultSet.next()) {
// Printing results to the console
System.out.println("descrip- " + resultSet.getString("descrip"));
}
// setting the row to we have to update
resultSet.first();
// Setting the updating String
resultSet.updateString("descrip", "wamp");
// Updating the first row
resultSet.updateRow();
System.out.println("\n\n After Updatig.......................\n");
while (resultSet.next()) {
// Printing results to the console
System.out.println( "descrip- " + resultSet.getString("descrip"));
}
} catch (Exception e) {
System.out.println(e.toString());
} finally {
connection.close();
}
}ولكني لا احصل على اي نتيجة وانما يظهر الاتي
PostgreSQL 8.4 JDBC3 (build 702)
Found in: jar:file:/C:/Users/Dalia/Desktop/postgresql-8.4-702.jdbc3.jar!/org/postgresql/Driver.class
ماهي المشكلة؟؟
