I've download Microsoft SQL Server 2000 JDBC Driver. All these files are being installed and saved in a folder called sql. For example, the IP adress is 255.255.255.255 , I updated the code and saved it as test1.java in this manner:
import java.sql.*;
/**
* Microsoft SQL Server JDBC test program
*/
public class test1 {
public test1() throws Exception {
// Get connection
DriverManager.registerDriver(new
com.microsoft.jdbc.sqlserver.SQLServerDriver());
Connection connection = DriverManager.getConnection(
"jdbc:microsoft:sqlserver:@.255.255.255","abc","abc");
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 {
test1 test = new test1();
}
}
I'm able to compile but when I run the program, the given error is:
Exception in thread "main" java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect. Invalid URL.
at com.microsoft.jdbc.base.BaseExceptions.createExcep tion(Unknown Source
)
at com.microsoft.jdbc.base.BaseExceptions.getExceptio n(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager .java:512)
at java.sql.DriverManager.getConnection(DriverManager .java:171)
at test1.<init>(test1.java:10)
at test1.main(test1.java:31)
I have checked that the given IP address is correct, so please can anyone enlighten me about the problem.
Thanks.You must set your database name and port number such as following
Connection connection = DriverManager.getConnection(
"jdbc:microsoft:sqlserver:@.255.255.255:1433;Databas eName=MyDB","abc","abc");
You can also use your computer name in url
"jdbc:microsoft:sqlserver://MYSERVER:1433;DatabaseName=MYDB","USERID","PASSWORD"
Originally posted by diablos00
I've download Microsoft SQL Server 2000 JDBC Driver. All these files are being installed and saved in a folder called sql. For example, the IP adress is 255.255.255.255 , I updated the code and saved it as test1.java in this manner:
import java.sql.*;
/**
* Microsoft SQL Server JDBC test program
*/
public class test1 {
public test1() throws Exception {
// Get connection
DriverManager.registerDriver(new
com.microsoft.jdbc.sqlserver.SQLServerDriver());
Connection connection = DriverManager.getConnection(
"jdbc:microsoft:sqlserver:@.255.255.255","abc","abc");
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 {
test1 test = new test1();
}
}
I'm able to compile but when I run the program, the given error is:
Exception in thread "main" java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect. Invalid URL.
at com.microsoft.jdbc.base.BaseExceptions.createExcep tion(Unknown Source
)
at com.microsoft.jdbc.base.BaseExceptions.getExceptio n(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager .java:512)
at java.sql.DriverManager.getConnection(DriverManager .java:171)
at test1.<init>(test1.java:10)
at test1.main(test1.java:31)
I have checked that the given IP address is correct, so please can anyone enlighten me about the problem.
Thanks.|||I had the same problem,
The problem is that the Microsoft jdbc driver used unicode and Ianywhere can't handle it.
Use an other jdbc driver from a 3de party will solve this problem.
I used the jdbc driver from datadirect (Type 4 jdbc driver) and this one
was working perfectly. Only thing is you have to pay for it.
I hope i could help you with this.
Greetz|||Microsofts JDBC driver works just fine. In fact it's an old data direct Type 4 driver. Make sure you have the service pack 1 jdbc driver. Here's the exact connection url I use with no problems.
jdbc:jtds:sqlserver://tlmssql3:1388/db1;USER=appsrv1;PASSWORD=password;TDS=8.0
No comments:
Post a Comment