import java.net.URL;
import java.util.*;
import java.sql.*;

class Select {
  public static void main(String argv[]) {
    try {
      Class.forName("org.gjt.mm.mysql.Driver");
      String url = "jdbc:mysql://dehua:3306/test";
      Properties prop = new Properties();
      prop.put("UID","dehua");
      prop.put("PWD","yangdehua");
      
//      Connection con = DriverManager.getConnection(url, prop);
      Connection con = DriverManager.getConnection(url, (String)prop.get("UID"),
                       (String)prop.get("PWD"));
      Statement stmt = con.createStatement();
      ResultSet rs =
	  stmt.executeQuery("SELECT * from test");

      ResultSetMetaData meta = rs.getMetaData();

      System.out.println("Got results:");
      while(rs.next()) {
	String a= rs.getString("name");
	String str = rs.getString("number");

	System.out.print(" name = " + a);
	System.out.print(" number = " + str);
	System.out.print("\n");
      }
//      int count = stmt.executeUpdate("INSERT INTO test values('aaaaaaaaa',200)"); 
//      count = stmt.executeUpdate("INSERT INTO test values('中国人民',200)"); 
//      count = stmt.executeUpdate("INSERT INTO test values('我们罚款',200)"); 
      stmt.close();
      DatabaseMetaData dbmd = con.getMetaData();
      rs = dbmd.getTables(null, null, null, null);
      while( rs.next() ) {
	  System.out.println("Table: " + rs.getString("TABLE_NAME"));
      }
      con.close();
    }
    catch( Exception e ) {
      System.out.println(e.getMessage());
      e.printStackTrace();
    }
  }
}
  
