I was doing a java program with embedded sql database by using derby. I inserted many rows but when I selected
我添加的所有行,它仅显示我添加的前2行和当前添加的行。
{
Driver derbyEmbeddedDriver = new EmbeddedDriver();
DriverManager.registerDriver(derbyEmbeddedDriver);
conn = DriverManager.getConnection("jdbc:derby:testdb1;", "root","");
conn.setAutoCommit(false);
stmt = conn.createStatement();
pstmt = conn.prepareStatement("insert into gamedate(gamedate,currentdate) values('"+gamedat``e+"','"+gamedate+"')");//gamedate is a string,gamedate and currentdate are columns of database table
System.out.println("insert into gamedate(gamedate,currentdate) values("+gamedate+","+gamedate+")");
pstmt.executeUpdate();
rs = stmt.executeQuery("select * from gamedate");
while (rs.next()) {
System.out.printf("%d %s %s \n",rs.getInt("id"), rs.getString("gamedate"),rs.getString("currentdate"));
}