Terminate () throwsIOException {PreparedStatementpsnull; Connectionconnull; terminate (newFileReader (Path. path_read_beijing); StringBuffersnull; StringBufferwayIdnull; StringBufferisWay...
Public void Get_WayId_Ref_isWay () throws IOException
{
PreparedStatement ps = null; Connection con = null; BufferedReader br = new BufferedReader (new FileReader (Path. path_read_beijing); StringBuffer s = null; StringBuffer wayId = null; StringBuffer isWay = new StringBuffer ("false"); String regex_nd = "\ d +"; // Match
Tmp = new ArrayList
(); // Find the information of the way class if (batchCount % 100 = 0) {ps. clearBatch () ;}if (s. indexOf ("
0) {// Obtain each group of WayId Pattern p1 = Pattern. compile (regex_id); Matcher m1 = p1.matcher (s); if (m1.find () {wayId = new StringBuffer (m1.group ();} while (s. indexOf ("
") <= 0) {count ++; s = new StringBuffer (br. readLine (); // Obtain the refid if (s. indexOf ("
0) {System. out. println ("number of rows:" + count); Pattern p = Pattern. compile (regex_nd); Matcher m = p. matcher (s); if (m. find () {tmp. add (new StringBuffer (m. group () ;}}// determine whether the way is road if (s. indexOf ("
0 | s. indexOf ("
0 | s. indexOf ("
0) {isWay = new StringBuffer ("true") ;}} for (int I = 0; I
ps=con.prepareStatement(sql1.toString());
ps.addBatch();
} ps.executeBatch(); if(batchCount%100==0) { con.commit(); } } } } con.commit(); } catch (Exception e) { e.printStackTrace(); // TODO: handle exception }finally{ try { if(ps!=null) ps.close(); if(con!=null) con.close(); } catch (Exception e2) { e2.printStackTrace(); } } }
The error message is:
Java. SQL. SQLException: java. lang. OutOfMemoryError: Java heap space
At com. mysql. jdbc. SQLError. createSQLException (SQLError. java: 1055)
At com. mysql. jdbc. SQLError. createSQLException (SQLError. java: 956)
At com. mysql. jdbc. SQLError. createSQLException (SQLError. java: 926)
At com. mysql. jdbc. Util. handleNewInstance (Util. java: 430)
At com. mysql. jdbc. PreparedStatement. getInstance (PreparedStatement. java: 561)
At com. mysql. jdbc. ConnectionImpl. clientPrepareStatement (ConnectionImpl. java: 1395)
At com. mysql. jdbc. ConnectionImpl. prepareStatement (ConnectionImpl. java: 4178)
At com. mysql. jdbc. ConnectionImpl. prepareStatement (ConnectionImpl. java: 4077)
At Wayid_To_ SQL .Get_Map_Line_beta.Get_WayId_Ref_isWay (Get_Map_Line_beta.java: 128)
At Wayid_To_ SQL .Get_Map_Line_beta.main (Get_Map_Line_beta.java: 35)