This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes jsp/sql server connection problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jsp/sql server connection problem" Watch "jsp/sql server connection problem" New topic
Author

jsp/sql server connection problem

Manas Dabz
Greenhorn

Joined: Mar 26, 2003
Posts: 5
I am trying to connect sql server 2000 in jsp using sql tags.
connection code goes like -

<sql:setDataSource
var="example"
driver="com.microsoft.jdbc.sqlserver.SQLServerDriver"
url="jdbc:microsoft:sqlserver://192.168.254.15:1433"
user="user"
password="password" />

I am getting following exception -

type Exception report

message

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

exception

javax.servlet.ServletException: Unable to get connection, DataSource invalid: "java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user 'administrator'. Reason: Not associated with a trusted SQL Server connection."
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.createtable_jsp._jspService(createtable_jsp.java:87)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


root cause

javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user 'administrator'. Reason: Not associated with a trusted SQL Server connection."
org.apache.taglibs.standard.tag.common.sql.UpdateTagSupport.getConnection(Unknown Source)
org.apache.taglibs.standard.tag.common.sql.UpdateTagSupport.doStartTag(Unknown Source)
org.apache.jsp.createtable_jsp._jspx_meth_sql_update_0(createtable_jsp.java:126)
org.apache.jsp.createtable_jsp._jspService(createtable_jsp.java:72)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.25 logs.
Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
I know I'm not really answering your question but...

Most web programmers concur that it is not a good idea to connect and interact with a database from a JSP because JSPs are for presentation logic and not business logic. You might want to look into the Model View Controller architecture. Using this method, you would connect to the database in a regular class (or servlet) and populate a javabean that holds the result of the database interaction and stick it in a context the JSP can reach, such as request. Then, your JSP page can simply use the bean for rendering rather than accessing the database. Just a suggestion.
Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
I can't really tell you where the error is. But based on my experience, I usually firstly do a simple pure java , not JSP/Servlet, to test if the little application can access the remote database or not. If successful, then move to JSP/Servlet.

This way can seperate the possible error in Server from the error of driver, user/pass, connection string. because it is hard to tell the error from web server error message.

But I still want to say, it will better to set DAO class to do all of database connection. This DAO class will be a re-usable component for you and it will save you in next time.

Edward
Ivor Lithan
Greenhorn

Joined: May 30, 2004
Posts: 10
What mode of security are you running on your sql box? - 2000 sets the mode to windows authentication as standard - you may want to try setting it to mixed mode - and seeing if that works
Madeswaran Pachiyappan
Greenhorn

Joined: Jun 29, 2004
Posts: 7
Check the DSN Username and Password.Also Check the ODBCAD32,where the authenticity is through SQL Server Authentication.And Client Configuration is through TCP/IP.


Madeswaran P,<br />Chennai,<br />TamilNadu.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

...and finally: MS's JDBC Driver is very intollerant of poorly configured SQL Server instances. And it just so happens that SQL server is poorly configured by default. If you are not too experienced configuring SQL Server, try jTDS as your driver instead (google for it). It's a better driver anyway.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Moving this to the JDBC forum... it's really a database problem, not a JSP problem.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp/sql server connection problem
 
Similar Threads
Error while jsp connecting to database
Error
Cannot find ActionMappings or ActionFormBeans collection
Whats Happening?
Cannot find ActionMappings or ActionFormBeans collection