import java.sql.*;
public class ConnectionDatabaseDemo
{
public ConnectionDatabaseDemo()
{
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName = JAVA ";
String userName = "sa";
String password = "";
Connection con = DriverManager.getConnection(url,userName,password);
}
catch(SQLException e)
{
e.printStackTrace();
}
catch(ClassNotFoundException ex)
{
ex.printStackTrace();
}
}
public static void main(String[] args)
{
new ConnectionDatabaseDemo();
}
}
我的这个又错在哪里了`
----------------解决方案--------------------------------------------------------
报错了?DatabaseName = JAVA 这句不要有空格看看……
----------------解决方案--------------------------------------------------------
恩 我去试一下`
----------------解决方案--------------------------------------------------------