我的错误!
DBConnection2.java:38:未报告的异常 java.lang.InstantiationException;必须被捕获或声明被抛出 Class.forName("com.mysql.jdbc.Driver").newInstance();
问题:.newInstance();
我的代码:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.*;
import java.util.*;
import java.sql.*;
import java.util.StringTokenizer;
public class DBConnection2 {
String url = "jdbc:mysql://<myserver>/<myDatabase>";
java.sql.Connection con = null;
String query1;
Statement stmt;
public DBConnection2()
{
try
{
//***error here*****
Class.forName("com.mysql.jdbc.Driver").newInstance();
//***error here*****
}
catch(java.lang.ClassNotFoundException e)
{
System.err.println(e.getMessage());
}
try
{
con = java.sql.DriverManager.getConnection(url,"read","read");
stmt = con.createStatement();
}
catch(SQLException ex)
{
System.err.println("SQLException:72 appserver " + ex.getMessage());
}
}
}