Showing posts with label jdbc. Show all posts
Showing posts with label jdbc. Show all posts

Wednesday, March 28, 2012

How to connect to sql server2005 from java using JDBC driver

Hi, everyone:
I need to connect my java app to sql server 2005 using JDBC driver, but I don't know how to do.
Thanks for your help.
AdolfoWe currently have a beta2 driver availalbe for this now:

http://www.microsoft.com/sql/downloads/2005/jdbc.mspx

To connect:

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:sqlserver://mysqlserver;user=myuser;password=mypassword;databaseName=mydataBase;");

|||

Ok. happen that I have installed the sqlserver 2005 beta 2, using windows authentication, so it needs a name instance to get access. When I use the JDBC driver I can't connect using that name instance.

regards,

Adolfo

|||The beta version of windows authentication has some known issues -- did you try connection to the named instance with SQL Server authentication?

-shelby

How to connect to sql server2005 from java using JDBC driver

Hi, everyone:
I need to connect my java app to sql server 2005 using JDBC driver, but I don't know how to do.
Thanks for your help.
AdolfoWe currently have a beta2 driver availalbe for this now:

http://www.microsoft.com/sql/downloads/2005/jdbc.mspx

To connect:

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:sqlserver://mysqlserver;user=myuser;password=mypassword;databaseName=mydataBase;");|||

Ok. happen that I have installed the sqlserver 2005 beta 2, using windows authentication, so it needs a name instance to get access. When I use the JDBC driver I can't connect using that name instance.

regards,

Adolfo

|||The beta version of windows authentication has some known issues -- did you try connection to the named instance with SQL Server authentication?

-shelby

Wednesday, March 21, 2012

How to connect database under Windows Authentication?

Hi, all. I develop my JDBC program under SQL SERVER Authentication using Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
Connection con = DriverManager.getConnection("jdbc:sqlserver://dataserver:1433; DatabaseName=database", username, password);
It works well.
After my company update the database to SQL SERVER 2005 using Windows Authentication. My program sucks.
I want to know the format of JDBC connectivity code for Windows Authentication, as similar as the code I post above? Anyone can help me?

Hi there,

As far as I am aware, the SQL Server 2005 JDBC driver does not currently support Windows Authentication. Checking out the documentation I found here seems to indicate that Windows Auth doesn't work as setting the integratedSecurity property to "true" (implying Windows Auth) produces an exception.

You could try jTDS (http://jtds.sourceforge.net/faq.html). The project seems to be dead at the moment but you can still download the required files. It supports Windows Auth and in the connection string you have to use the domain property and specify what domain you are on (same domain as the SQL Server you are trying to connect to, of course).

The relevant information is all in the FAQ (the jTDS link I gave above).

Good luck & sorry I couldn't be of more help at the mo.

Monday, March 12, 2012

How to configure distributed transaction / XA support using Microsoft SQL Server 2005 JDBC Drive


I am trying to configure distributed transaction and XA support using Microsoft SQL Server 2005 JDBC Driver. I have coppied SQLJDBC_XA.dll from XA directory and placed in my sql server binn directory and trying to run the script xa_install.sql from binn directory with command as below :

C:\Program Files\Microsoft SQL Server\80\Tools\Binn>
osql -U sa -n -P admin -S localhost -i C:\JavaLibraries\MS SQL Driver\sqljdbc_1.2\enu\xa\ xa_install.sql

But I am getting error saying :
[DBNETLIB]SQL Server does not exist or access denied.
[DBNETLIB]ConnectionOpen (Connect()).

when I replaced local host with the machine name it gives error :
[Shared Memory]SQL Server does not exist or access denied.
[Shared Memory]ConnectionOpen (Connect()).

where in I am able to test connection from Websphere using the same connection.

Please help some one ....... I am in URGENT need.... I need to enable XA suport for my application to run........

Thanks -
This looks like a connectivity issue. Do you have this problem only with osql? Can you connect using Query analyzer?|||

I was able to install the SQLJDCB_XA.dll with the exception that I copied it into a different directory:

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn

Have you tried that?

Regards.

How to configure distributed transaction / XA support using Microsoft SQL Server 2005 JDBC Drive


I am trying to configure distributed transaction and XA support using Microsoft SQL Server 2005 JDBC Driver. I have coppied SQLJDBC_XA.dll from XA directory and placed in my sql server binn directory and trying to run the script xa_install.sql from binn directory with command as below :

C:\Program Files\Microsoft SQL Server\80\Tools\Binn>
osql -U sa -n -P admin -S localhost -i C:\JavaLibraries\MS SQL Driver\sqljdbc_1.2\enu\xa\ xa_install.sql

But I am getting error saying :
[DBNETLIB]SQL Server does not exist or access denied.
[DBNETLIB]ConnectionOpen (Connect()).

when I replaced local host with the machine name it gives error :
[Shared Memory]SQL Server does not exist or access denied.
[Shared Memory]ConnectionOpen (Connect()).

where in I am able to test connection from Websphere using the same connection.

Please help some one ....... I am in URGENT need.... I need to enable XA suport for my application to run........

Thanks -
This looks like a connectivity issue. Do you have this problem only with osql? Can you connect using Query analyzer?|||

I was able to install the SQLJDCB_XA.dll with the exception that I copied it into a different directory:

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn

Have you tried that?

Regards.