Код: Выделить всё
java.sql.Connection conn = null;
try
{
String userName = "root";
String password = "***";
String url = "jdbc:mysql://localhost/mydb";
Class.forName ("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection (url, userName, password);
Statement stat = (Statement) conn.createStatement();
ResultSet res = stat.executeQuery("SELECT count(*) FROM `chat_companies`; ");
if (res.next()){
System.out.println("Count rows in table: " + res.getInt(1));
}
}
catch (Exception e)
{
System.err.println (e.getMessage());
}
finally
{
if (conn != null)
{
try
{
conn.close ();
}
catch (Exception e) {e.printStackTrace(); }
}
}
- 10-24 13:25:27.833: W/dalvikvm(1015): VFY: unable to find class referenced in signature (Ljavax/naming/Reference;)
10-24 13:25:27.833: I/dalvikvm(1015): Could not find method javax.naming.Reference.get, referenced from method com.mysql.jdbc.ConnectionPropertiesImpl$ConnectionProperty.initializeFrom
10-24 13:25:27.843: W/dalvikvm(1015): VFY: unable to resolve virtual method 11733: Ljavax/naming/Reference;.get (Ljava/lang/String;)Ljavax/naming/RefAddr;
10-24 13:25:27.843: D/dalvikvm(1015): VFY: replacing opcode 0x6e at 0x0004
10-24 13:25:27.853: W/dalvikvm(1015): VFY: unable to find class referenced in signature (Ljavax/naming/Reference;)
10-24 13:25:27.853: E/dalvikvm(1015): Could not find class 'javax.naming.StringRefAddr', referenced from method com.mysql.jdbc.ConnectionPropertiesImpl$ConnectionProperty.storeTo
10-24 13:25:27.853: W/dalvikvm(1015): VFY: unable to resolve new-instance 1026 (Ljavax/naming/StringRefAddr;) in Lcom/mysql/jdbc/ConnectionPropertiesImpl$ConnectionProperty;
10-24 13:25:27.853: D/dalvikvm(1015): VFY: replacing opcode 0x22 at 0x0006
10-24 13:25:27.873: D/dalvikvm(1015): DexOpt: unable to opt direct call 0x2dd7 at 0x14 in Lcom/mysql/jdbc/ConnectionPropertiesImpl$ConnectionProperty;.storeTo
10-24 13:25:28.533: D/dalvikvm(1015): GC_CONCURRENT freed 251K, 4% free 9680K/9991K, paused 82ms+117ms, total 544ms
10-24 13:25:29.403: I/dalvikvm(1015): Could not find method java.lang.management.ManagementFactory.getThreadMXBean, referenced from method com.mysql.jdbc.MysqlIO.appendDeadlockStatusInformation
10-24 13:25:29.403: W/dalvikvm(1015): VFY: unable to resolve static method 10767: Ljava/lang/management/ManagementFactory;.getThreadMXBean ()Ljava/lang/management/ThreadMXBean;
10-24 13:25:29.403: D/dalvikvm(1015): VFY: replacing opcode 0x71 at 0x0079
10-24 13:25:29.953: W/System.err(1015): Communications link failure
10-24 13:25:29.953: W/System.err(1015): The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.