晚安伙计们!
我在java中创建了与Derby的连接,我在表中插入数据,但是当我运行代码以使用System.out.printl在表中显示数据时,Java给了我一个消息连接Ok!但没有什么可以告诉我控制台上的数据,我正在使用子句SELECT * FROM ...我会发布代码,如果他们有更多的示例代码,或者选择发送另一个代码将被很好地接受,看我的代码:
package tests ;
import java.sql . * ;
public class AcessoBanco {
public static void main ( String [ ] args ) {
Connection con = null;
try {
con = DriverManager.getConnection ( " jdbc : derby : database " , " Ramom " , " banco123 " ) ;
Statement sta = con.createStatement ( ) ;
// Getting the data back
ResultSet res = sta.executeQuery ( " SELECT * FROM APP.TablePTBR " ) ;
while ( res.next ()) {
// THIS LINE(SYSTEM.OUT...) DOES NOT SEEM TO BE WORKING, PLEASE take a look !
System.out.println ( res.getInt ("code") + " , " + res.getString ( "user " ) ) ;
}
res.close ();
sta.close ();
con.close ();
} Catch ( Exception e ) {
System.err.println ( " Exception : " + e.getMessage ( ) ) ;
}
}
}
我的问题是没有连接,但问题是SELECT和使用System.out.println在JAVA控制台中查看表数据,当我运行命令“Insert Into ...”时,java没有显示任何连接错误,没有错误插入,当我在Derby表中检查GUI时,那里没有数据.. 谢谢你们!