Showing posts with label files. Show all posts
Showing posts with label files. Show all posts

Tuesday, March 27, 2012

connecting to SQL Server 2000 using JDBC

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

Thursday, March 22, 2012

connecting to server outside network

I'm trying to move some files from our in-house server to a server at our
ISP. I'm using the dts wizard. For the source, I put in the IP address of our
ih-house server. When I click "refresh" to get a list of the databases I get
this error:
Error source: Microsoft OLE DB Provider for SQL Server
Error Description: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does
not exist or access denied.
Context: Error during intialiaztion of the provider.
I am able to ping the in-house sever from the ISP server. I can log in to
the in-house using query analyzer and the login and password that I'm putting
in the dts wizard.
Any idea what might be wrong?
Thanks,
Dan D.
Problem solved. It was a setting in our firewall.
Dan D.
"Dan D." wrote:

> I'm trying to move some files from our in-house server to a server at our
> ISP. I'm using the dts wizard. For the source, I put in the IP address of our
> ih-house server. When I click "refresh" to get a list of the databases I get
> this error:
> Error source: Microsoft OLE DB Provider for SQL Server
> Error Description: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does
> not exist or access denied.
> Context: Error during intialiaztion of the provider.
> I am able to ping the in-house sever from the ISP server. I can log in to
> the in-house using query analyzer and the login and password that I'm putting
> in the dts wizard.
> Any idea what might be wrong?
> Thanks,
> --
> Dan D.

connecting to server outside network

I'm trying to move some files from our in-house server to a server at our
ISP. I'm using the dts wizard. For the source, I put in the IP address of our
ih-house server. When I click "refresh" to get a list of the databases I get
this error:
Error source: Microsoft OLE DB Provider for SQL Server
Error Description: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does
not exist or access denied.
Context: Error during intialiaztion of the provider.
I am able to ping the in-house sever from the ISP server. I can log in to
the in-house using query analyzer and the login and password that I'm putting
in the dts wizard.
Any idea what might be wrong?
Thanks,
--
Dan D.Problem solved. It was a setting in our firewall.
--
Dan D.
"Dan D." wrote:
> I'm trying to move some files from our in-house server to a server at our
> ISP. I'm using the dts wizard. For the source, I put in the IP address of our
> ih-house server. When I click "refresh" to get a list of the databases I get
> this error:
> Error source: Microsoft OLE DB Provider for SQL Server
> Error Description: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does
> not exist or access denied.
> Context: Error during intialiaztion of the provider.
> I am able to ping the in-house sever from the ISP server. I can log in to
> the in-house using query analyzer and the login and password that I'm putting
> in the dts wizard.
> Any idea what might be wrong?
> Thanks,
> --
> Dan D.

connecting to server outside network

I'm trying to move some files from our in-house server to a server at our
ISP. I'm using the dts wizard. For the source, I put in the IP address of ou
r
ih-house server. When I click "refresh" to get a list of the databases I get
this error:
Error source: Microsoft OLE DB Provider for SQL Server
Error Description: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server
does
not exist or access denied.
Context: Error during intialiaztion of the provider.
I am able to ping the in-house sever from the ISP server. I can log in to
the in-house using query analyzer and the login and password that I'm puttin
g
in the dts wizard.
Any idea what might be wrong?
Thanks,
--
Dan D.Problem solved. It was a setting in our firewall.
--
Dan D.
"Dan D." wrote:

> I'm trying to move some files from our in-house server to a server at our
> ISP. I'm using the dts wizard. For the source, I put in the IP address of
our
> ih-house server. When I click "refresh" to get a list of the databases I g
et
> this error:
> Error source: Microsoft OLE DB Provider for SQL Server
> Error Description: [DBNETLIB][ConnectionOpen (Connect()).]SQL Serv
er does
> not exist or access denied.
> Context: Error during intialiaztion of the provider.
> I am able to ping the in-house sever from the ISP server. I can log in to
> the in-house using query analyzer and the login and password that I'm putt
ing
> in the dts wizard.
> Any idea what might be wrong?
> Thanks,
> --
> Dan D.

Thursday, March 8, 2012

Connecting to AdventureWorks2000_Data.mdf

When I try to connect to this AdventureWorks2000_Data.mdf, I get the following message:

The file "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks2000_Data.mdf" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.

Could not open new database 'AdventureWorks2000'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 5118)

Any ideas on how to get the local version installed of SQL Server to open this db? I'm trying to follow along with the examples in the book "Beginning Transact-SQL with SQL Server 2000 and 2005".

Thanks,

Vanzant

Run a sp_helpdb to check all the databases in your server just to make sure you do have the AdventureWorks2000 database. If not, you can download it from

http://www.microsoft.com/downloads/details.aspx?FamilyID=487C9C23-2356-436E-94A8-2BFB66F0ABDC&displaylang=en

|||

Is C: a compressed volume? If so, SQL Server does not support compressed volumes.

Read SQL Server databases are not supported on compressed volumes

|||http://blogs.msdn.com/sanchan/archive/2006/06/04/617585.aspx FYI.|||

I don't think C: is a compressed volume. The only thing I know to check is the disk properties when right click on C:. It isn't selected on the "compress drive to save disk space". If there is another place to check/correct, please let me know.

I can open the AdventureWorks_Data.mdf. I don't know if this matters but I have SQL Server 2005 and SQL Server Express installed on my local PC. This is where I'm trying to look at the files. I'm not sure the differences between the AdventureWorks_Data and AdventureWorks2000_Data, but I don't understand why I can't open the '2000' version.

Any ideas/help would be greatly appreciated.

Thanks,

Vanzant

|||

I think I've figured it out. There are two folders (MSSQL and MSSQL.1) under the Microsoft SQL Server folder. I attached the 2000 db in the MSSQL folder and it worked. I guess it is a newbie issue.

Thanks for inputs!