Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-01-16 : 11:28:34
|
Yun writes "We purchased SQL Server 2000, installed it in a PC machine as a Data Server, set up connection between this pc and Unix machine. We can ping the machine each other.Then we download the MS SQL Server 2000 Driver, installed it the Unix machine, set up the environment and ran the test code. But we got the Exceptions, the connection was failed. Attached are the test code and error message. Hope someone can help.ThanksYun******** test code **************mport java.sql.*;/** * Microsoft SQL Server JDBC test program */public class Test { public Test() throws Exception { // Get connection DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver()); Connection connection = DriverManager.getConnection( "jdbc:microsoft:sqlserver://<hostname>:1433","<username>","<password>"); if (connection != null) { System.out.println(); System.out.println("Successfully connected"); System.out.println(); // Meta data DatabaseMetaData meta = connection.getMetaData(); System.out.println("\nDriver Information"); System.out.println("Driver Name: " + meta.getDriverName()); System.out.println("Driver Version: " + meta.getDriverVersion()); System.out.println("\nDatabase Information "); System.out.println("Database Name: " + meta.getDatabaseProductName()); System.out.println("Database Version: "+ meta.getDatabaseProductVersion()); } } // Test public static void main (String args[]) throws Exception { Test test = new Test(); }}******** error message **************Exception in thread "main" java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket. at java.lang.Throwable.fillInStackTrace(Native Method) at java.lang.Throwable.fillInStackTrace(Compiled Code) at java.lang.Throwable.<init>(Compiled Code) at java.lang.Exception.<init>(Compiled Code) at java.sql.SQLException.<init>(SQLException.java:64) at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source) at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source) at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source) at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source) at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(Compiled Code) at java.sql.DriverManager.getConnection(DriverManager.java:137) at Test.<init>(Test.java:10) at Test.main(Test.java:32)******* end of message ***************" |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-01-16 : 11:32:27
|
Only thing I can think of is maybe the SQL Server is not configured to listen on port 1433, or that a firewall may be in place that is blocking that port. Also, have you tried connecting to SQL Server from another PC?Unfortunately I don't have any experience with JDBC drivers, and if the above suggestions check out I can't think of anything else on the SQL Server end that might be causing the trouble. |
 |
|
|
|
|