السلام عليكم
كتبت هذا الكود بالجافا لقاعدة بيانات postgresql
لا تظهر لي اي اخطاء في الكود لكني لم احصل على اي نتيجة
ماهي المشكلة؟؟
import java.sql.*;
class SelectQuery {
static void main(String[] args) {
try {
// Connection
String url = "jdbc:postgresql:Database Summer";
Class. forName("org.postgresql.Driver") ;
Connection connection = DriverManager.getConnection(url,"postgres", "password") ;
// Executing SQL-command
String sqlcommand = "SELECT * FROM cust";
Statement statement = connection.createStatement() ;
ResultSet res = statement.executeQuery(sqlcommand) ;
// Displaying the output
int outp;
while(res.next())
{
outp = res.getInt(1) ;
System.out.println("Result: " + outp + "\n") ;
}
connection. close() ;
}
// Catching the exception
catch (java.lang.Exception ex) {
System.out.println("Connect and execute query: " + ex) ; }
}