This thread has been locked & this forum has been archived.
Please post new topics to Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Author Message
toddcorley
Veteran Member
Veteran Member


Joined: Jan 12, 2006
Posts: 15

I found this example and it works fine:
Code:
import java.sql.*;

public class Test
{
   public static void main(String[] args)
   {
      try
      {
         java.lang.Class
               .forName( "com.microsoft.sqlserver.jdbc.SQLServerDriver" );
         Connection c = java.sql.DriverManager
               .getConnection( "jdbc:sqlserver://localhost\SQLEXPRESS;user=SQLDATAUSER;password=database;" );
         System.out.println( "Connected!" );
      }
      catch( Exception ex )
      {
         ex.printStackTrace();
      }
   }
}


But I can't figure out how to configure it as a jdbc driver in the Database Explorer setup.
Using the drivers down loaded from: http://www.microsoft.com/downloads/details.aspx?familyid=e22bc83b-32ff-4474-a44a-22b6ae2c4e17&displaylang=en

I have read lots of stuff about the older three jar driver set, but they seem to have gone to a single jar.


In the driver set up I have the provide jar added to the driver libraries: \sqljdbc_1.0\enu\sqljdbc_1.0\enu\sqljdbc.jar
I have tried many different variations of the url from the example above, but can't get the data connection to connect.

Here is the error from the .log file:
Code:

!ENTRY com.genuitec.eclipse.sqlexplorer 4 4 2006-01-23 22:33:22.125
!MESSAGE Error while trying to login to database
!STACK 0
com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the named instance  has failed. Error: java.net.SocketTimeoutException: Receive timed out.
   at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
   at com.microsoft.sqlserver.jdbc.SQLServerConnection.getInstancePort(Unknown Source)
   at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
   at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
   at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(SQLDriverManager.java:99)
   at com.genuitec.eclipse.sqlexplorer.actions.LoginProgress$Login.run(LoginProgress.java:43)
   at java.lang.Thread.run(Unknown Source)


Anyone know what I am doing wrong?
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
toddcorley
Veteran Member
Veteran Member


Joined: Jan 12, 2006
Posts: 15

The correct URL line for the new driver is:
Code:
jdbc:sqlserver://localhost\SQLEXPRESS
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-rkalla
Registered Member
Registered Member


Joined: Jan 06, 2004
Posts: 23818

Did you do the steps outlined in the document here: http://www.myeclipseide.com/images/tutorials/quickstarts/dbexplorer/

start in section 4.1?

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
toddcorley
Veteran Member
Veteran Member


Joined: Jan 12, 2006
Posts: 15

Yes, but it didn't help in this case.

The problem was that the example url:
Code:
jdbc:microsoft:sqlserver://<server_name>:<1433>


looks very little like the new url needed for SQL server 2005:
Code:
jdbc:sqlserver://localhost\SQLEXPRESS


What would have helped would have been being able to see the connection attempt by the DB Browser. Is there any logging setting that would echo its calls to what ever db it is using?
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-rkalla
Registered Member
Registered Member


Joined: Jan 06, 2004
Posts: 23818

Quote:

What would have helped would have been being able to see the connection attempt by the DB Browser. Is there any logging setting that would echo its calls to what ever db it is using?

No not at this time, although I believe this is a filed enhancement.

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
ngo
Registered Member
Registered Member


Joined: Mar 09, 2005
Posts: 27

Try the following procedure:

Install SQL Server 2005 Express with Mix Mode Authentication, which will require you to enter the password for 'sa' (make sure you write it down and remember after the installation; you can use it to connect to the database).

Enable TCP/IP network protocol, which is disable by default, and set the TCP/IP port to 1433 by following instructions below:

1) Open the SQL Server 2005 Configuration Manager by selecting Start->All Programs->Microsoft Server 2005->Configuration Tools->SQL Server Configuration Manager

2) Click on the SQL Server Network Configuration node to expand it

3) Click on Protocols for SQLEXPRESS node

4) Right click on the TCP/IP protocol on the right panel and select Enable

5) Right click on the TCP/IP protocol on the right panel and click Properties

6) Click on the IP Address tab

7) On the IPAll section, clear out the TCP Dynamic Ports field and enter 1433 (which is the default port for SQL Server 2005) on the TCP Port field

Disable the firewall on the machine that houses the SQL Server Express


You should be able to test the connection by using the following connection URL:

jdbc:sqlserver://<server>

where <server> is the server name or IP address of the machine the houses the SQL Server Express

Good luck!
 
 View user's profile Send private message  
Reply with quote Back to top
zulfikhar



Joined: Nov 15, 2007
Posts: 2

hello this is zulfikhar
i am trying to connect to my sql server 200 database through database explorer
and i have add the respective jar file also , but still it giving the error that can't connect to databas
 
 View user's profile Send private message  
Reply with quote Back to top
zulfikhar



Joined: Nov 15, 2007
Posts: 2

can any one tell me which url i should use to connect and in that url how to specify our dsn name
 
 View user's profile Send private message  
Reply with quote Back to top
myeclipse.is.great



Joined: Nov 08, 2007
Posts: 10

Hi,

You should try to use jTDS driver for MSSQL since it faster and much more reliable.
See : http://jtds.sourceforge.net/
It is well documented too.
I use it for years without problem.
 
 View user's profile Send private message  
Reply with quote Back to top
SNK111



Joined: Jul 06, 2010
Posts: 1

Check this article ( http://www.shahriarnk.com/Shahriar-N-K-Research-Embedding-SQL-in-C-Sharp-Java.html ) for details on how to connect to SQL Server database from C#.NET database applications as well as Java database applications. It also describes how to pass embedded SQL queries (SELECT, INSERT, UPDATE, DELETE), calling stored procedures, pass parameters etc.
 
 View user's profile Send private message  
Reply with quote Back to top
All times are GMT - 6 Hours
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
® 2014 - Genuitec, LLC.