• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp/sql server connection problem

 
Manas Dabz
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...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.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the JDBC forum... it's really a database problem, not a JSP problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic