Home > Back-end > Java servlet cycle to insert 1 million oracle data problem, please help solve, in a hurry
Java servlet cycle to insert 1 million oracle data problem, please help solve, in a hurry
Time:09-27
Demand is this: the existing 1 million data needs to be inserted into the oracle database, data format for the XML format, the need to parse and extract the key data and written to the database, parsing, written to the database are no problem, but in the time of more than 2000 libraries fail, can't write the database, the code is as follows:
Public class DBhelp { The static String driver;//oracle driver The static String url="JDBC: oracle: thin: @ 192.168.5.16:1521: noCard"; The static String user="card22";//user is the database user name The static String password="card11";
Public static Connection getconn () {//in order to facilitate the interpretation of the following, set up a special used for database Connection here a method The Connection conn=null; Try { //first establish drive Class.forname ("... The oracle JDBC driver OracleDriver "); //after the success of the drive to connect Conn=DriverManager. GetConnection (url, user, password); } the catch (SQLException e) { e.printStackTrace(); } the catch (Exception e) { e.printStackTrace(); } Return the conn.//return a connection } Public static int the insert (String SQL) { The Connection conn=null; The Statement st=null; Conn=getconn (); //get connection Int result; Try { St=conn. CreateStatement (); //create the SQL insert //return a result, do this either success or failure, if the returned result & gt; 0 is success, and vice failure Result=st. executeUpdate (SQL); } the catch (SQLException e) { //TODO Auto - generated the catch block, Result=0; e.printStackTrace(); } return result; } }
SQL statements:
Try { String SQL="insert into JingDong (TRX_CODE) values ('" + TRX_CODE + "', ');" Logger. The info (" SQL: "+ SQL); Int aa=DBhelp. Insert (SQL); } the catch (JDOMException e) { Logger. The info (" explain the error message, the message format is not correct "); } the catch (Exception e) { Logger. The info (" error: "+ um participant etMessage ()); }
Um participant etMessage () - output is null
CodePudding user response:
The code posted all? Didn't see you close connection,