Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help with ms sql server 2005

 
Dhruva Mistry
Ranch Hand
Posts: 67
Eclipse IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Vijitha Kumara
Bartender
Pie
Posts: 3918
10
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Dhruva Mistry
Ranch Hand
Posts: 67
Eclipse IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
Eclipse IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dhruva Mistry
Ranch Hand
Posts: 67
Eclipse IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
Eclipse IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the stack trace you are getting?

 
Dhruva Mistry
Ranch Hand
Posts: 67
Eclipse IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
Eclipse IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic