错误: 在类 test.test 中找不到 main 方法, 请将 main 方法定义为: public static void main(String[
package test;
import java.sql.*;
public class test{
public static void main(String [] args) throws Exception
{
String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=jack_sql";
String userName="sa";
String userPwd="123456789";
try
{
Class.forName(driverName);
System.out.println("加载驱动成功!");
}catch(Exception e){
e.printStackTrace();
System.out.println("加载驱动失败!");
}
try{
Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd);
System.out.println("连接数据库成功!");
}catch(Exception e)
{
e.printStackTrace();
System.out.print("SQL Server连接失败!");
}
Connection Conn=DriverManager.getConnection(dbURL,userName,userPwd);
Statement stat=Conn.createStatement();
}
}