aspose file tools*
The moose likes JDBC and the fly likes help with ms sql server 2005 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "help with ms sql server 2005" Watch "help with ms sql server 2005" New topic
Author

help with ms sql server 2005

Dhruva Mistry
Ranch Hand

Joined: Nov 21, 2008
Posts: 67

Hello All,

i could not understand how to connect ms sql server 2005 with simple java code. more specifically i am unaware of what can be placed for DB url?

i have connected to DSN for ms sql using SQLSRVR.dll file.

do i need any separate driver?

i am unaware of what to be written for making DB URL for my machine.

please help me with this.

Thanks in advance.

Regards,


Dhruva
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3825

i could not understand how to connect ms sql server 2005 with simple java code. more specifically i am unaware of what can be placed for DB url?


You will have to download the JDBC driver for the sql server you are using and check the driver documentation which explains how to work with it.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

dhruva mistry wrote:
i could not understand how to connect ms sql server 2005 with simple java code. more specifically i am unaware of what can be placed for DB url?

Have you tried some code for using JDBC, If not, then try this tutorial.
dhruva mistry wrote:
do i need any separate driver?

Yes, Find it here


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Dhruva Mistry
Ranch Hand

Joined: Nov 21, 2008
Posts: 67

Thank you very much for directing me Vijitha Kumara and Sagar Rohankar.

i have got jtds driver for ms sql server 2005 but reading its spec i am not understanding how to install it
so i tried to do that also in eclipse and when i do TestDriver, it throws exception related to URL

in the spec format given :
i m providing:

also found the properties user and password are required so i put

for eclipse i added driver's jar file tooo

but unable to find out how to make it work in eclipse or to install to use normally with ms sql serevr 2005

would you please help me out with any of these?

Thank you very much fro your kind support.

Regards
Dhruva Mistry
Ranch Hand

Joined: Nov 21, 2008
Posts: 67

when i use URL, eclipse TestDriver throws Network Error IOException:connection refused :
jdbc:jtds:sqlserver://DHRUVA:1433/master;user=sa;password=sql2005



my LAN connection and SQL SERVER AGENT are running well.

please help me.

Regards
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

jTDS is just a Java application, it is installed if it is on your classpath.

Have another look at the documentation, you are missing the required forward slashes.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Dhruva Mistry
Ranch Hand

Joined: Nov 21, 2008
Posts: 67

Paul Sturrock wrote:jTDS is just a Java application, it is installed if it is on your classpath.

Have another look at the documentation, you are missing the required forward slashes.


Thanks Paul Sturrock,
i edited my recent post.

any suggestions for IOEXception error?

Thanks Paul!

Regards
Dhruva Mistry
Ranch Hand

Joined: Nov 21, 2008
Posts: 67

Paul Sturrock wrote:jTDS is just a Java application, it is installed if it is on your classpath.

Have another look at the documentation, you are missing the required forward slashes.


i have provided Driver Classname correct one in Eclipse.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

dhruva mistry wrote:
jdbc:jtds:sqlserver://DHRUVA:1433/master;user=sa;password=sql2005


Try using IP address instead of machine name, DHRUVA.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Can you post the stack trace you are getting?

Dhruva Mistry
Ranch Hand

Joined: Nov 21, 2008
Posts: 67

Sagar Rohankar wrote:
dhruva mistry wrote:
jdbc:jtds:sqlserver://DHRUVA:1433/master;user=sa;password=sql2005


Try using IP address instead of machine name, DHRUVA.


tried using localhost and IP instead machine name but not worked
well, what is application class path? is it
and is the jar file needs to be placed under that path?

also i am just trying to connect the DB and TestDriver in eclipse successfully
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

dhruva mistry wrote:
Sagar Rohankar wrote:
well, what is application class path? is it
and is the jar file needs to be placed under that path?

Why tomcat directory, I supposed you're creating a simple standalone Java code, which gets connected with db only ?
And there is nothing like "application class path", I know only CLASSPATH, where required .jar files PATH is specified.

And yes, Look at what Paul suggested ?
Dhruva Mistry
Ranch Hand

Joined: Nov 21, 2008
Posts: 67

Thanks Mr. Paul and Mr. Rohan, i have not any stack trace for driver connection in eclipse
issue thrown : network error: io exception: connection refused

and, normally, should i place jar files under folder having jsp files? if i am having java files along with jsp files?

Thank you for helping me out.

Regards,
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

dhruva mistry wrote:Thanks Mr. Paul and Mr. Rohan,

Its Sagar, Rohan is part of my surname
dhruva mistry wrote:i have not any stack trace for driver connection in eclipse
issue thrown : network error: io exception: connection refused

Have you used Exception#printStackTrace() in your catch block?
dhruva mistry wrote:
and, normally, should i place jar files under folder having jsp files? if i am having java files along with jsp files?

JAR files are library files, and they MUST resides in WEB-INF/lib directory, Having .java files with jsp files, not what recommended, they MUST be in /src directory.

and Look what I had suggested you in my earlier post, Try simple Java code with main method
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Thanks Mr. Paul and Mr. Rohan, i have not any stack trace for driver connection in eclipse
issue thrown : network error: io exception: connection refused

So you must not be loggin the stack trace. Can you post your code?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help with ms sql server 2005