ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/tags/aglappe-0.6/testMySQLConnection.java
Revision: 197
Committed: Thu Jun 14 14:44:44 2007 UTC (17 years, 4 months ago) by duarte
File size: 969 byte(s)
Log Message:
Tagging version 0.6 for release of cmview 0.6
Line File contents
1 import tools.MySQLConnection;
2
3 import java.sql.SQLException;
4 import java.sql.Statement;
5 import java.sql.ResultSet;
6
7 public class testMySQLConnection {
8
9 /**
10 * "Hello World" for a MySQLConnection to white
11 *
12 * @author duarte
13 */
14
15 static String user = "duarte" ; // change user name!!
16
17 public static void main(String[] args) {
18
19 MySQLConnection conn = new MySQLConnection("white",user,"nieve","newmsdgraph");
20
21 try {
22 String sql = "SELECT num,res FROM nodes limit 3;";
23 Statement stmt = conn.createStatement();
24 ResultSet rsst = stmt.executeQuery(sql);
25 while (rsst.next()) {
26 int num = rsst.getInt(1); // 1st column -- num
27 String res = rsst.getString(2); // 2nd column -- res
28 System.out.println("serial number: "+num+", residue type: "+res);
29 }
30 } catch (SQLException e) {
31 e.printStackTrace();
32 System.err.println("SQLException: " + e.getMessage());
33 System.err.println("SQLState: " + e.getSQLState());
34 }
35
36 }
37
38 }