Today is 5.3,哪位大侠帮帮忙啊! Parse S0 in JAVA use MYSQL?大侠帮帮忙!
How to use Jave solve the parse problem , I use Java named ReadFile.java read in "transitions " but I only need the last part s1 or s2 how to do that?
//it locates the c:/eclipse/workspace2/JDBC/src/TestMysqlConnectionimport java.sql.*;public class TestFSMMysqlConnection {
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null; try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager
.getConnection("jdbc:mysql://localhost/myfsmdata?user=root&password=root");
stmt = conn.createStatement();
rs = stmt.executeQuery("select transitions from fsm2");
while (rs.next()) {
System.out.println(rs.getString("transitions"));
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}finally{
try{
if(rs!=null){
rs.close();
rs=null;
}
if(stmt!=null){
stmt.close();
stmt=null;
}
if (conn !=null){
conn.close();
conn=null;
}
}catch(SQLException e){
e.printStackTrace();
}
}
}
} how to parse the result last part :s1 or s2
*******************************************************************
// result of ReadFile.java on May2,2008s0,input-stay,s0
s0,input-forward,s1
s1,input-stay,s1
s1,input-forward,s2
s2,input-stay,s2
s2,input-back,s0
How to use Jave solve the parse problem , I use Java named ReadFile.java read in "transitions " but I only need the last part s1 or s2 how to do that?
//it locates the c:/eclipse/workspace2/JDBC/src/TestMysqlConnectionimport java.sql.*;public class TestFSMMysqlConnection {
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null; try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager
.getConnection("jdbc:mysql://localhost/myfsmdata?user=root&password=root");
stmt = conn.createStatement();
rs = stmt.executeQuery("select transitions from fsm2");
while (rs.next()) {
System.out.println(rs.getString("transitions"));
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}finally{
try{
if(rs!=null){
rs.close();
rs=null;
}
if(stmt!=null){
stmt.close();
stmt=null;
}
if (conn !=null){
conn.close();
conn=null;
}
}catch(SQLException e){
e.printStackTrace();
}
}
}
} how to parse the result last part :s1 or s2
*******************************************************************
// result of ReadFile.java on May2,2008s0,input-stay,s0
s0,input-forward,s1
s1,input-stay,s1
s1,input-forward,s2
s2,input-stay,s2
s2,input-back,s0
He may not know his problems at all.