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

class Select {
  public static void main(String argv[]) {
    try {
      Class.forName("com.imaginary.sql.msql.MsqlDriver");
      String url = "jdbc:msql://dehua:1114/UserBase";
      Connection con = DriverManager.getConnection(url, "dehua", "yangdehua");
      Statement stmt = con.createStatement();
      ResultSet rs =
	  stmt.executeQuery("SELECT * from userpassword order by Userid");

      ResultSetMetaData meta = rs.getMetaData();

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

	System.out.print(" Userid = " + a);
	System.out.print(" Pass = " + str);
	System.out.print("\n");
      }
      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();
    }
  }
}
  
