如何使用mysql将所有记录保存在derby中

时间:2018-08-16 16:57:56

标签: java mysql sql netbeans derby

 I was doing a java program with embedded sql database by using derby. I inserted many rows but when I selected

image

我添加的所有行,它仅显示我添加的前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"));
     }

0 个答案:

没有答案