/**
* Created by gqdw on 9/28/16.
*/
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
public class MyTest {
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://xxx.27.199.225/myzb";
static final String USER = "";
static final String PASS = "";
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
try{
Class.forName("com.mysql.jdbc.Driver1");
System.out.println("connecting to database...");
conn = DriverManager.getConnection(DB_URL,USER,PASS);
stmt = conn.createStatement();
String sql0;
sql0 = "select eventid,clock from events limit 10";
ResultSet rs = stmt.executeQuery(sql0);
while(rs.next()){
Integer eventid = rs.getInt("eventid");
Integer clock = rs.getInt("clock");
System.out.println("eventid: " + eventid + "\t" + "clock:" + clock);
}
rs.close();
stmt.close();
conn.close();
}catch(ClassNotFoundException ce){
System.out.println("Class not found.");
ce.printStackTrace();
System.exit(1);
}
catch(SQLException se){
se.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}
}
}