if(bsid == 639){
//create table GALLOPING_AD(GALLOPING_AD_ID NUMBER(19) not null,BS_ID NUMBER(19),SENSOR_ID NUMBER(19),TIMESTAMP VARCHAR2(19),NUM_TIME NUMBER(19),AD_X VARCHAR2(4000),AD_Y VARCHAR2(4000),AD_Z VARCHAR2(4000),G_X CLOB,G_Y CLOB,G_Z CLOB);
//alter table GALLOPING_AD add constraint GALLOPING_AD_PK primary key (GALLOPING_AD_ID) using index;
Connection conn = null;
PreparedStatement prepStat = null;
ResultSet rs= null;
try {
conn = DBCon.getCon(2);
conn.setAutoCommit(false);
String s_sql = "insert into GALLOPING_AD(BS_ID,SENSOR_ID,TIMESTAMP,NUM_TIME,AD_X,AD_Y,AD_Z,G_X,G_Y,G_Z) values(?,?,?,?,?,?,?,empty_clob(),empty_clob(),empty_clob())";
prepStat = conn.prepareStatement(s_sql);
prepStat.setInt(1, bsid);
prepStat.setInt(2, sensorid);
prepStat.setString(3, DateTimeTool.long2date(datatime));
prepStat.setLong(4, datatime);
StringBuilder sb_adx = new StringBuilder();
for(int i = 0;i < adX.length;i++){
if(i > 0) sb_adx.append(",");
sb_adx.append(adX[i]);
}
//System.out.println("ad_x:" + sb_adx.toString());
byte [] arrb_adx = sb_adx.toString().getBytes();
StringBuilder sb_ady = new StringBuilder();
for(int i = 0;i < adY.length;i++){
if(i > 0) sb_ady.append(",");
sb_ady.append(adY[i]);
}
//System.out.println("ad_y:" + sb_ady.toString());
byte [] arrb_ady = sb_ady.toString().getBytes();
StringBuilder sb_adz = new StringBuilder();
for(int i = 0;i < adZ.length;i++){
if(i > 0) sb_adz.append(",");
sb_adz.append(adZ[i]);
}
//System.out.println("ad_z:" + sb_adz.toString());
byte [] arrb_adz = sb_adz.toString().getBytes();
prepStat.setCharacterStream(6, new InputStreamReader(new ByteArrayInputStream(arrb_adx)),arrb_adx.length);
prepStat.setCharacterStream(7, new InputStreamReader(new ByteArrayInputStream(arrb_ady)),arrb_ady.length);
prepStat.setCharacterStream(5, new InputStreamReader(new ByteArrayInputStream(arrb_adz)),arrb_adz.length);
int result = prepStat.executeUpdate();
if(result == 1){
prepStat = null;
String s_update = "select G_X,G_Y,G_Z from GALLOPING_AD where BS_ID=" + bsid + " and SENSOR_ID=" + sensorid + " and NUM_TIME=" + datatime + " for update";
//System.out.println(s_update);
prepStat = conn.prepareStatement(s_update);
rs = prepStat.executeQuery();
if(rs.next()){
StringBuilder sb_gx = new StringBuilder();
for(int i = 0;i < ax.length;i++){
if(i > 0) sb_gx.append(",");
sb_gx.append(ax[i]);
}
//System.out.println("gx:" + sb_gx.toString());
StringBuilder sb_gy = new StringBuilder();
for(int i = 0;i < ay.length;i++){
if(i > 0) sb_gy.append(",");
sb_gy.append(ay[i]);
}
//System.out.println("gy:" + sb_gy.toString());
StringBuilder sb_gz = new StringBuilder();
for(int i = 0;i < az.length;i++){
if(i > 0) sb_gz.append(",");
sb_gz.append(az[i]);
}
//System.out.println("gz:" + sb_gz.toString());
oracle.sql.CLOB clob_gx = (oracle.sql.CLOB)rs.getClob("G_X");
BufferedWriter writer_gx = new BufferedWriter(clob_gx.getCharacterOutputStream());
writer_gx.write(sb_gx.toString());
writer_gx.flush();
writer_gx.close();
oracle.sql.CLOB clob_gy = (oracle.sql.CLOB)rs.getClob("G_Y");
BufferedWriter writer_gy = new BufferedWriter(clob_gy.getCharacterOutputStream());
writer_gy.write(sb_gy.toString());
writer_gy.flush();
writer_gy.close();
oracle.sql.CLOB clob_gz = (oracle.sql.CLOB)rs.getClob("G_Z");
BufferedWriter writer_gz = new BufferedWriter(clob_gz.getCharacterOutputStream());
writer_gz.write(sb_gz.toString());
writer_gz.flush();
writer_gz.close();
}
}
conn.commit();
conn.setAutoCommit(true);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
} finally {
DBCon.attemptClose(prepStat);
DBCon.attemptClose(conn);
}
/*StringBuilder sb_temp = new StringBuilder("insert into GALLOPING_AD(BS_ID,SENSOR_ID,TIMESTAMP,NUM_TIME,AD_X,AD_Y,AD_Z) values(");
sb_temp.append(bsid);
sb_temp.append(",").append(sensorid);
sb_temp.append(",'").append(DateTimeTool.long2date(datatime)).append("'");
sb_temp.append(",").append(datatime);
sb_temp.append(",'");
for(int i = 0;i < adX.length;i++){
if(i > 0) sb_temp.append(",");
sb_temp.append(adX[i]);
}
sb_temp.append("','");
for(int i = 0;i < adY.length;i++){
if(i > 0) sb_temp.append(",");
sb_temp.append(adY[i]);
}
sb_temp.append("','");
for(int i = 0;i < adZ.length;i++){
if(i > 0) sb_temp.append(",");
sb_temp.append(adZ[i]);
}
sb_temp.append("')");
Memory.getSQLQueue().add(sb_temp.toString());*/
}
//create table GALLOPING_AD(GALLOPING_AD_ID NUMBER(19) not null,BS_ID NUMBER(19),SENSOR_ID NUMBER(19),TIMESTAMP VARCHAR2(19),NUM_TIME NUMBER(19),AD_X VARCHAR2(4000),AD_Y VARCHAR2(4000),AD_Z VARCHAR2(4000),G_X CLOB,G_Y CLOB,G_Z CLOB);
//alter table GALLOPING_AD add constraint GALLOPING_AD_PK primary key (GALLOPING_AD_ID) using index;
Connection conn = null;
PreparedStatement prepStat = null;
ResultSet rs= null;
try {
conn = DBCon.getCon(2);
conn.setAutoCommit(false);
String s_sql = "insert into GALLOPING_AD(BS_ID,SENSOR_ID,TIMESTAMP,NUM_TIME,AD_X,AD_Y,AD_Z,G_X,G_Y,G_Z) values(?,?,?,?,?,?,?,empty_clob(),empty_clob(),empty_clob())";
prepStat = conn.prepareStatement(s_sql);
prepStat.setInt(1, bsid);
prepStat.setInt(2, sensorid);
prepStat.setString(3, DateTimeTool.long2date(datatime));
prepStat.setLong(4, datatime);
StringBuilder sb_adx = new StringBuilder();
for(int i = 0;i < adX.length;i++){
if(i > 0) sb_adx.append(",");
sb_adx.append(adX[i]);
}
//System.out.println("ad_x:" + sb_adx.toString());
byte [] arrb_adx = sb_adx.toString().getBytes();
StringBuilder sb_ady = new StringBuilder();
for(int i = 0;i < adY.length;i++){
if(i > 0) sb_ady.append(",");
sb_ady.append(adY[i]);
}
//System.out.println("ad_y:" + sb_ady.toString());
byte [] arrb_ady = sb_ady.toString().getBytes();
StringBuilder sb_adz = new StringBuilder();
for(int i = 0;i < adZ.length;i++){
if(i > 0) sb_adz.append(",");
sb_adz.append(adZ[i]);
}
//System.out.println("ad_z:" + sb_adz.toString());
byte [] arrb_adz = sb_adz.toString().getBytes();
prepStat.setCharacterStream(6, new InputStreamReader(new ByteArrayInputStream(arrb_adx)),arrb_adx.length);
prepStat.setCharacterStream(7, new InputStreamReader(new ByteArrayInputStream(arrb_ady)),arrb_ady.length);
prepStat.setCharacterStream(5, new InputStreamReader(new ByteArrayInputStream(arrb_adz)),arrb_adz.length);
int result = prepStat.executeUpdate();
if(result == 1){
prepStat = null;
String s_update = "select G_X,G_Y,G_Z from GALLOPING_AD where BS_ID=" + bsid + " and SENSOR_ID=" + sensorid + " and NUM_TIME=" + datatime + " for update";
//System.out.println(s_update);
prepStat = conn.prepareStatement(s_update);
rs = prepStat.executeQuery();
if(rs.next()){
StringBuilder sb_gx = new StringBuilder();
for(int i = 0;i < ax.length;i++){
if(i > 0) sb_gx.append(",");
sb_gx.append(ax[i]);
}
//System.out.println("gx:" + sb_gx.toString());
StringBuilder sb_gy = new StringBuilder();
for(int i = 0;i < ay.length;i++){
if(i > 0) sb_gy.append(",");
sb_gy.append(ay[i]);
}
//System.out.println("gy:" + sb_gy.toString());
StringBuilder sb_gz = new StringBuilder();
for(int i = 0;i < az.length;i++){
if(i > 0) sb_gz.append(",");
sb_gz.append(az[i]);
}
//System.out.println("gz:" + sb_gz.toString());
oracle.sql.CLOB clob_gx = (oracle.sql.CLOB)rs.getClob("G_X");
BufferedWriter writer_gx = new BufferedWriter(clob_gx.getCharacterOutputStream());
writer_gx.write(sb_gx.toString());
writer_gx.flush();
writer_gx.close();
oracle.sql.CLOB clob_gy = (oracle.sql.CLOB)rs.getClob("G_Y");
BufferedWriter writer_gy = new BufferedWriter(clob_gy.getCharacterOutputStream());
writer_gy.write(sb_gy.toString());
writer_gy.flush();
writer_gy.close();
oracle.sql.CLOB clob_gz = (oracle.sql.CLOB)rs.getClob("G_Z");
BufferedWriter writer_gz = new BufferedWriter(clob_gz.getCharacterOutputStream());
writer_gz.write(sb_gz.toString());
writer_gz.flush();
writer_gz.close();
}
}
conn.commit();
conn.setAutoCommit(true);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
} finally {
DBCon.attemptClose(prepStat);
DBCon.attemptClose(conn);
}
/*StringBuilder sb_temp = new StringBuilder("insert into GALLOPING_AD(BS_ID,SENSOR_ID,TIMESTAMP,NUM_TIME,AD_X,AD_Y,AD_Z) values(");
sb_temp.append(bsid);
sb_temp.append(",").append(sensorid);
sb_temp.append(",'").append(DateTimeTool.long2date(datatime)).append("'");
sb_temp.append(",").append(datatime);
sb_temp.append(",'");
for(int i = 0;i < adX.length;i++){
if(i > 0) sb_temp.append(",");
sb_temp.append(adX[i]);
}
sb_temp.append("','");
for(int i = 0;i < adY.length;i++){
if(i > 0) sb_temp.append(",");
sb_temp.append(adY[i]);
}
sb_temp.append("','");
for(int i = 0;i < adZ.length;i++){
if(i > 0) sb_temp.append(",");
sb_temp.append(adZ[i]);
}
sb_temp.append("')");
Memory.getSQLQueue().add(sb_temp.toString());*/
}