Hi Guys, can anyone help me solve this issue? i tried on other method it works but I don’t know why it can’t work over here. Below is my code
public void extractLog(String logString)
{
PreparedStatement pstmtRunTime = null;
StringTokenizer stToken = new StringTokenizer(logString);
String currentToken;
String a="1";
String b="2";
String c="3";
String d="4";
String e="5";
boolean update= false;
LG_updateID="0";
int count=1;
currentToken=stToken.nextToken().trim();
LG_updateID = currentToken;
while(stToken.hasMoreTokens())
{
currentToken=stToken.nextToken().trim();
count++;
if(LG_updateID.equals("1")) //string for bus loading/unloading
{
if(count==4)
{
LG_Time=currentToken;
System.out.println(currentToken);
}
else if(count==7)
{
LG_busID=currentToken;
System.out.println(currentToken);
}
else if(count==10)
{
LG_numPassenger_Board=currentToken;
System.out.println(currentToken);
}
else if(count==13)
{
LG_numPassenger_Alight=currentToken;
System.out.println(currentToken);
}
else if(count==17)
{
LG_busStopID=currentToken;
System.out.println(currentToken);
update = true;
}
//update
/* String SQLRun_Time = "insert into runtime_update (LG_updateID,LG_Time,LG_busID,LG_numPassenger_Board,LG_numPassenger_Alight,LG_busStopID)"
+ "value ('"+LG_updateID+"','"+LG_Time+"','"+LG_busID+"','"+LG_numPassenger_Board+"','"+LG_numPassenger_Alight+"','"+LG_busStopID+"')";*/
//String SQLRun_Time = "insert into runtime_update ("+"LG_updateID,"+"LG_Time,"+"LG_busID,"+"LG_numPassenger_Board,"+"LG_numPassenger_Alight,"+"LG_busStopID)"+"value (?,?,?,?,?,?)";
String SQLRunTime = "INSERT INTO runtime_update VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
if(update==true)
{
System.out.println("test");
try
{
//stmt.executeUpdate(SQLRun_Time);
pstmtRunTime = con.prepareStatement(SQLRunTime);
System.out.println("test2");
pstmtRunTime.setString(1, LG_updateID);
pstmtRunTime.setString(2, LG_busID);
pstmtRunTime.setString(3, LG_numPassenger_Board);
pstmtRunTime.setString(4, LG_numPassenger_Alight);
pstmtRunTime.setString(5, LG_busStopID);
pstmtRunTime.setString(6, LG_busStopID2);
pstmtRunTime.setString(7, LG_numPassenger);
pstmtRunTime.setString(8, LG_numPassenger_Reached_Dest);
pstmtRunTime.setString(9, LG_trafficLightID);
pstmtRunTime.setString(10, LG_Time);
pstmtRunTime.setString(11, LG_TLO_NSStatus);
pstmtRunTime.setString(12, LG_TLO_EWStatus);
//pstmtRuneTime.setInt(13, LG_busStopID);
pstmtRunTime.executeUpdate();
update =false;
}
catch (Exception ex)
{
update = false;
System.out.println("Fail to update");
}
}
}
}
}