-1

Java プログラムを使用して、あるサーバーから別のサーバーに値を挿入しようとしています。これが私のコードです:-

public static void main(String[] args) throws FileNotFoundException {
    // TODO code application logic here

    try {
        Class.forName("oracle.jdbc.OracleDriver");
    } catch (Exception exception) {
    }

    Connection conn = null;
    Connection conn1 = null;

    ResultSet rs, rs1 = null;

    Statement pst = null;


    try {
        //      dbConnect.executequery(sdate, edate);
        conn = DriverManager.getConnection("jdbc:oracle:thin:@31.4.224.76:1521:RPTPSG", "pihist", "pihist");
        String query = "select * from messagemasterhistory where ROWNUM<=1572660";
        // String query="select * from messagemasterhistory where createdate>='28-JAN-11' and createdate<='18-FEB-2011'";
        pst = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);

        // String sql="insert into test(SRN ,UTR) values (";
        // pst=conn.prepareStatement(sql);

        // rs.absolute(2000);
        //  pst.setFetchSize(2000);
        //  pst.setMaxRows(1500000);
        pst.setFetchDirection(ResultSet.FETCH_FORWARD);

        rs = pst.executeQuery(query);

        //  String statment="insert into test(UTR,SRN) values('abc','1')";

        //  PrintWriter wt=new PrintWriter("ritima2.txt");
        conn1 = DriverManager.getConnection("jdbc:oracle:thin:@31.4.224.81:1521:RPTPSG", "rptr", "rptr");
        Statement stat1 = conn1.createStatement();
        while (rs.next()) {
            String str = rs.getString("FIELDDATA");
            String str1 = rs.getString("FIELDINFO");
            String statment = "insert into MESSAGEMASTERHISTORY2(UTR,CREATEDATE,SENDER,RECEIVER,SUBMESSAGETYPE,FIELDINFO,FIELDDATA,DUPLICATE) values(" + "'" + rs.getString("UTR") + "'" + "," + "TO_DATE('" + rs.getDate("CREATEDATE") + "'" + ",'YYYY-MM-DD\" \"HH24:MI:SS')" + "," + "'" + rs.getString("SENDER") + "'" + "," + "'" + rs.getString("RECEIVER") + "'" + "," + "'" + rs.getString("SUBMESSAGETYPE") + "'" + "," + "'" + str1 + "'" + "," + "'" + str + "'" + "," + rs.getInt("DUPLICATE") + ")";
            // String statment="insert into test1 (fielddata,utr) values("+"'"+(rs.getString("fielddata"))+"'"+","+"'"+rs.getString("UTR")+"')";
            System.out.println(count);
            stat1.executeQuery(statment);

            System.out.println(str);
            System.out.println(str1);
            // System.out.println(rs.getClob("FIELDDATA"));
            System.gc();
            count++;
        }
        conn1.commit();
        conn1.close();
        // wt.close();
        System.out.println("Completed");
        conn.close();

    } catch (Exception e) {
        e.printStackTrace();

    }

}
}            

いくつかの行 (6274) を挿入した後、「java.sql.SQLException: ORA-00917: カンマがありません」というエラーが発生します

    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:754)
    at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:210)
    at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:963)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1192)
    at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1315)
    at javaapplication2.Main.main(Main.java:73)
4

2 に答える 2