我用的是myeclipse开发工具,我用加载mysql驱动包,这是简单的测试代码:
java.sql.Connection conn=null;
try{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
conn=java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","0215");
System.out.println("数据库连接成功");
}catch(Exception ex){
ex.printStackTrace();
}
出现的错误代码:
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:262 com.mysql.jdbc.Buffer.readByte()
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:262 com.mysql.jdbc.Buffer.readByte(..) returning 24
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:232 com.mysql.jdbc.Buffer.getPosition()
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:232 com.mysql.jdbc.Buffer.getPosition(..) returning 1
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:185 com.mysql.jdbc.Buffer.getBufLength()
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:185 com.mysql.jdbc.Buffer.getBufLength(..) returning 30
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:211 com.mysql.jdbc.Buffer.getBytes(0, 1)
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:211 com.mysql.jdbc.Buffer.getBytes(..) returning [B@1ff48d8
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:185 com.mysql.jdbc.Buffer.getBufLength()
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:185 com.mysql.jdbc.Buffer.getBufLength(..) returning 30
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- MysqlIO.java:2907 com.mysql.jdbc.MysqlIO.checkErrorPacket(..) returning 18 .
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:232 com.mysql.jdbc.Buffer.getPosition()
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:232 com.mysql.jdbc.Buffer.getPosition(..) returning 1
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:185 com.mysql.jdbc.Buffer.getBufLength()
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:185 com.mysql.jdbc.Buffer.getBufLength(..) returning 30
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:211 com.mysql.jdbc.Buffer.getBytes(0, 1)
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:211 com.mysql.jdbc.Buffer.getBytes(..) returning [B@1077aa7
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:185 com.mysql.jdbc.Buffer.getBufLength()
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:185 com.mysql.jdbc.Buffer.getBufLength(..) returning 30
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- MysqlIO.java:885 com.mysql.jdbc.MysqlIO.checkErrorPacket(..) returning 18 .
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:232 com.mysql.jdbc.Buffer.getPosition()
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:232 com.mysql.jdbc.Buffer.getPosition(..) returning 1
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:458 com.mysql.jdbc.Buffer.setPosition(0)
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:458 com.mysql.jdbc.Buffer.setPosition(..) returning null
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:237 com.mysql.jdbc.Buffer.isLastDataPacket()
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:185 com.mysql.jdbc.Buffer.getBufLength()
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:185 com.mysql.jdbc.Buffer.getBufLength(..) returning 30
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:237 com.mysql.jdbc.Buffer.isLastDataPacket(..) returning false
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:306 com.mysql.jdbc.Buffer.readLenByteArray(0)
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:270 com.mysql.jdbc.Buffer.readFieldLength()
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:270 com.mysql.jdbc.Buffer.readFieldLength(..) returning 24
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:198 com.mysql.jdbc.Buffer.getBytes(24)
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:198 com.mysql.jdbc.Buffer.getBytes(..) returning [B@57df5
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:306 com.mysql.jdbc.Buffer.readLenByteArray(..) returning [B@57df5
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:306 com.mysql.jdbc.Buffer.readLenByteArray(0)
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:270 com.mysql.jdbc.Buffer.readFieldLength()
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:270 com.mysql.jdbc.Buffer.readFieldLength(..) returning 4
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:198 com.mysql.jdbc.Buffer.getBytes(4)
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:198 com.mysql.jdbc.Buffer.getBytes(..) returning [B@908f05
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:306 com.mysql.jdbc.Buffer.readLenByteArray(..) returning [B@908f05
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- MysqlIO.java:1360 com.mysql.jdbc.MysqlIO.nextRow(..) returning [[B@9dc8f2
Tue Jun 16 10:54:31 CST 2009 TRACE: --> MysqlIO.java:1360 com.mysql.jdbc.MysqlIO.nextRow([Lcom.mysql.jdbc.Field;@55a58f, 2, false, 1007)
Tue Jun 16 10:54:31 CST 2009 TRACE: --> MysqlIO.java:885 com.mysql.jdbc.MysqlIO.checkErrorPacket()
Tue Jun 16 10:54:31 CST 2009 TRACE: --> MysqlIO.java:2907 com.mysql.jdbc.MysqlIO.checkErrorPacket(-1)
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:232 com.mysql.jdbc.Buffer.getPosition()
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:232 com.mysql.jdbc.Buffer.getPosition(..) returning 30
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:185 com.mysql.jdbc.Buffer.getBufLength()
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:185 com.mysql.jdbc.Buffer.getBufLength(..) returning 30
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:211 com.mysql.jdbc.Buffer.getBytes(0, 30)
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:211 com.mysql.jdbc.Buffer.getBytes(..) returning [B@f38b42
Tue Jun 16 10:54:31 CST 2009 TRACE: --> Buffer.java:185 com.mysql.jdbc.Buffer.getBufLength()
Tue Jun 16 10:54:31 CST 2009 TRACE: <-- Buffer.java:185 com.mysql.jdbc.Buffer.getBufLength(..) returning 30
Tue Jun 16 10:54:31 CST 2009 TRACE: --> MysqlIO.java:2409 com.mysql.jdbc.MysqlIO.reuseAndReadPacket(Network packet, data follows:
18 6d 61 78 5f 6c 65 6e . m a x _ l e n
67 74 68 5f 66 6f 72 5f g t h _ f o r _
73 6f 72 74 5f 64 61 74 s o r t _ d a t
61 04 31 30 32 34 a . 1 0 2 4
。。。。。。。。一大堆这样的代码。。。。。
--转自