1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| String attribut= textField.getText() ;
String tab= textField_1.getText() ;
String url="jdbc:odbc:PostgreSQL";
Connection cox;
ResultSet result;
try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;}
catch(java.lang.ClassNotFoundException e)
{
System.err.print("ClassNotFoundException: ") ;
System.err.println(e.getMessage()) ;}
try{cox = DriverManager.getConnection(url,"postgres", "motpss") ;
String requette="SELECT"+ attribut+ "FROM"+tab; Statement stmt = cox.createStatement() ;
result = stmt.executeQuery(requette ) ;
while(result.next()){
System.out.print(result.getString(attribut)) ;
stmt.close() ;
cox.close() ;
}}
catch(SQLException ex)
{
System.err.println("SQLException: " + ex.getMessage()) ;
} |