|
请各位大哥帮我看看!急!
import java.sql.*;
import java.io.*;
import java.util.*;
import java.lang.*;
/**
This program tests that the database--MySQL and the JDBC
driver are correctly configured.
*/
public class TestDB2
{
public static void main (String args[])
{
try
{ Connection conn = null;
try{ Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url = "jdbc:mysql://localhost:3306/UDP_message";
String username = "root";
String password = "28201595";
conn = DriverManager.getConnection(url,username,password);
}
catch(ClassNotFoundException cnfex)
{ System.err.println("Again,Driver!");
System.exit(1);
}
catch(SQLException sqlex)
{ System.err.println("Con't connection!");
sqlex.printStackTrace();
System.exit(1);
}
Statement stat = conn.createStatement();
ResultSet result
= stat.executeQuery("SELECT * FROM UDP_message");
result.next();
System.out.println(result.getString(1));
result.close();
stat.close();
conn.close();
}
catch (SQLException ex)
{
while (ex != null)
{
ex.printStackTrace();
ex = ex.getNextException();
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
错误如图!! |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|