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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Having problems with sql connection" Watch "Having problems with sql connection" New topic
Author

Having problems with sql connection

Varun Nambuthiri
Ranch Hand

Joined: Sep 20, 2010
Posts: 76
hi

I am having problems with connecting ms sql server 2008 ...

At first i gave

and for some reason I had to change the computer I was working on so now its displaying "JavaScript Validator " and NullPointerException and now I m using ms sql server 2008 and previously I was using 2005

And I also something you should know that I was working on Eclipse Europa and now I am working on Helios

Thanks in advance


All's well that Debugs well .
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60077
    
  65

Moved to the JDBC forum. Hopefully you aren't doing this sort of thing in a JSP!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What sort of error do you see in the logs?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Varun Nambuthiri
Ranch Hand

Joined: Sep 20, 2010
Posts: 76
Ya sorry about that ..

So the error is about the problem in connection with the database and is showing given lines and the source of problems
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

A vague description of the error is hard to work with! Not sure we can help without more detail. A stack trace it will contain useful information, can you post it?
Varun Nambuthiri
Ranch Hand

Joined: Sep 20, 2010
Posts: 76
Now heres the stack trace

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: javax.servlet.ServletException: java.sql.SQLException: Network error IOException: Connection refused: connect
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:498)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:409)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause

javax.servlet.ServletException: java.sql.SQLException: Network error IOException: Connection refused: connect
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:898)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:827)
org.apache.jsp.jsp.checkuser_jsp._jspService(checkuser_jsp.java:129)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:73)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:378)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause

java.sql.SQLException: Network error IOException: Connection refused: connect
net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:410)
net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.apache.jsp.jsp.checkuser_jsp._jspService(checkuser_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:73)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:378)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause

java.net.ConnectException: Connection refused: connect
java.net.PlainSocketImpl.socketConnect(Native Method)
java.net.PlainSocketImpl.doConnect(Unknown Source)
java.net.PlainSocketImpl.connectToAddress(Unknown Source)
java.net.PlainSocketImpl.connect(Unknown Source)
java.net.SocksSocketImpl.connect(Unknown Source)
java.net.Socket.connect(Unknown Source)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:307)
net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:257)
net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:311)
net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.apache.jsp.jsp.checkuser_jsp._jspService(checkuser_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:73)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:378)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Connection refused: connect

Your connection has been refused. Things to check:
  • There is a server running at the host you specify
  • You are using the correct credentials to login
  • SQL Server is configured to support SQL server authentication (by default its not)
  • SQL Server is configured to allow connections over TCP/IP (by default it is not)
  • Varun Nambuthiri
    Ranch Hand

    Joined: Sep 20, 2010
    Posts: 76
    So how am I supposed to things 3 and 4 ?
    Paul Sturrock
    Bartender

    Joined: Apr 14, 2004
    Posts: 10336

    Either ask the person who administers your SQL server instance for you, or via management studio and the network configuration too.
    Varun Nambuthiri
    Ranch Hand

    Joined: Sep 20, 2010
    Posts: 76
    Now that is where the problem begins I am the one who "administers" sql server instance and have no idea what to do
    Paul Sturrock
    Bartender

    Joined: Apr 14, 2004
    Posts: 10336

    Well, the documentation covers most of this. If you are planning to do much administration I'd start to read through these. Long term this will make things easier.

    For now, to check what kind of authentication your instance supports use SQL Server Management Studio to view the security properties. By default it will be "Windows Authentication Mode"; for the connection string you supply you need "SQL Server and Windows Authentication Mode".

    To find out if your server is configured to allow connections over TCP/IP, use SQL Serve Configuration Manager. There's a section that lists the protocols enabled for your server.
    Varun Nambuthiri
    Ranch Hand

    Joined: Sep 20, 2010
    Posts: 76
    Thanks

    But the problem is I am a beginner to MS SQL server ....so I dont know anything about it ... please help or a decent documentation will do ...
    Paul Sturrock
    Bartender

    Joined: Apr 14, 2004
    Posts: 10336

    The documentation on MSDN is pretty comprehensive.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Having problems with sql connection
     
    Similar Threads
    Bulk data through JDBC
    I am facing a lot of problems with sql server 2000 odbc drivers.
    Facing Big Problem with Sql Server 2000 Odbc Driver
    visual J++ and retreiving rows from sql server
    Scrollable ResultSet