当前位置: 技术问答>java相关
连接数据库失败,请帮帮忙!
来源: 互联网 发布时间:2015-08-08
本文导语: 在JBuilder 6 + Weblogic 6.1 + MSSQLServer2000环境下: 执行下述代码时出现异常,请高手帮忙解决一下,在此谢过: Connection con = null; try { Class.forName("weblogic.jdbc.mssqlserver4.Driver"); jT...
在JBuilder 6 + Weblogic 6.1 + MSSQLServer2000环境下:
执行下述代码时出现异常,请高手帮忙解决一下,在此谢过:
Connection con = null;
try
{
Class.forName("weblogic.jdbc.mssqlserver4.Driver");
jTextArea2.setText("success 1");
con = DriverManager.getConnection ("jdbc:weblogic:mssqlserver4:Northwind@localhost","sa","pwd")
jTextArea2.setText("success 2");
Statement st = con.createStatement();
jTextArea2.setText("success 3");
ResultSet res = st.executeQuery("select * from Employees");
............
java.sql.SQLException: Can't open a socket on localhost:1433. Check host and port number and make sure the security manager allows this connection. You can also try running the SocketApplet (java.net.ConnectException: Connection refused: connect).
执行下述代码时出现异常,请高手帮忙解决一下,在此谢过:
Connection con = null;
try
{
Class.forName("weblogic.jdbc.mssqlserver4.Driver");
jTextArea2.setText("success 1");
con = DriverManager.getConnection ("jdbc:weblogic:mssqlserver4:Northwind@localhost","sa","pwd")
jTextArea2.setText("success 2");
Statement st = con.createStatement();
jTextArea2.setText("success 3");
ResultSet res = st.executeQuery("select * from Employees");
............
java.sql.SQLException: Can't open a socket on localhost:1433. Check host and port number and make sure the security manager allows this connection. You can also try running the SocketApplet (java.net.ConnectException: Connection refused: connect).
|
设置策略文件.
grant
{
permission java.security.AllPermission;
}
---------------
shmilu@sina.com
powered by csdn论坛助手
grant
{
permission java.security.AllPermission;
}
---------------
shmilu@sina.com
powered by csdn论坛助手
|
看看你的sql server的端口是不是1433。
|
根据提示显示,你没有用sqlserver的客户端进行联结,直接用socket联结的话,需要确认,数据库服务的socket连接方式是否已经启动,看看sqlserver关于这方面的帮助,应该需要一个启动端口的过程