private void dbCreate() { if (mConn == null) { return; } try { Statement stat = mConn.createStatement(); StringBuffer sqlCreate = new StringBuffer(); StringBuffer sqlInsert = new StringBuffer(); sqlCreate.append("CREATE TABLE "); sqlCreate.append(mTable); sqlCreate.append(" ("); sqlInsert.append("INSERT INTO "); sqlInsert.append(mTable); sqlInsert.append(" VALUES ("); for (int i = 0; i < mColumns.size(); i++) { if (i > 0) { sqlCreate.append(","); sqlInsert.append(","); } sqlCreate.append(mColumns.get(i).dbSpec); sqlInsert.append("?"); } sqlCreate.append(")"); sqlInsert.append(")"); stat.execute(sqlCreate.toString()); mSqlInsert = mConn.prepareStatement(sqlInsert.toString()); } catch (SQLException e) { e.printStackTrace(); dbAbort(); } }
private void dbEOL() { if (mConn == null) { return; } try { mSqlInsert.addBatch(); } catch (SQLException e) { e.printStackTrace(); dbAbort(); } }
private void dbEnd() { if (mConn == null) { return; } try { mSqlInsert.executeBatch(); mSqlInsert.close(); mConn.commit(); } catch (SQLException e) { e.printStackTrace(); } dbAbort(); }
private void dbField(int idx, String value) { if (mConn == null) { return; } try { if (mSqlInsert != null) { mSqlInsert.setString(idx + 1, value); } } catch (SQLException e) { e.printStackTrace(); dbAbort(); } }