Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

error 500 in JSP  RSS feed

 
northfield Sid
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting this error message but not sure what it means:
Error: 500
Location: /myJSPs/Hour17/updatePhoneBook.jsp
Internal Servlet Error:
javax.servlet.ServletException: [Microsoft][ODBC Driver Manager] Data source name too long
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
...
org.apache.tomcat.core.ContextManager.serviceat java.lang.Thread.run(Thread.java:484)
Root cause:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name too long
at
...
org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
...
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:484)
Here is the code:
<HTML>
<HEAD> <TITLE>Listing the content of a Database</TITLE> </HEAD>
<BODY>
<P> Content of the Phonebook database:
<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0>
<TR> <TD> Last </TD>
<TD> First </TD>
<TD> Phone </TD>
</TR>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc dbc NSEntry :/tomcat/jakarta-tomcat-3.3.1/webapps/myJSPs/Hour17/MyDatabase");
java.sql.Statement statement = connection.createStatement();
java.sql.ResultSet columns = statement.executeQuery("SELECT * FROM CONTACTTABLE");
while(columns.next()) {
String last = columns.getString("LAST");
String first = columns.getString("FIRST");
String phone = columns.getString("PHONE");%>
<TR> <TD> <%= last %> </TD>
<TD> <%= first %> </TD>
<TD> <%= phone %> </TD>
</TR>
<% } %>
</TABLE>
</BODY>
</HTML>
note the line regaarding driver class, i,e
Class.forName("...");
here I have tried:
Class.forName("com.sun.jdbc.odbc.Driver");
but still no luck.
The error is ambiguous
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to set up an ODBC data source for your database. You can't just use the file name. You have to give it an ODBC data source name.
 
northfield Sid
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created an ODBC Data Source from windows/control panel/User DSN tab/MS Access Database <is high-lighted>/add <button>/Mircorsoft Access driver <selected>/finish <button>
A new dialog box opens,
Data Source name: Mydatabase
Description: contacts database
Select <buttton> navigate to where the database is, I have called it Mydatabase ...

But it still does not work???
 
cardwell cupp
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once you set up the DSN on your machine, you do not have to specify where the database file is. Try just putting the dsn name down:
java.sql.DriverManager.getConnection("jdbc dbc:MyDatabaseDSN");
I hope this helps
Thanks
Cardwell
 
northfield Sid
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have tried the last suggestion get similar error
 
Shubhrajit Chatterjee
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem lies here ... it seems you have not configured your DSN properly...
1. User DSN should be OK if you strat your server using the same user id with which you logged on while creating DSN .... but you should be building a system DSN, whichs is more accessible to all users of your NT system
2. Have you set up your DSN properly ... check the DSN name you have given in ODBC and the name you are using in ypur application

3. Do you have a userid/password set in your DSN? If the answer is yes , then you need to suply userid password too.
4. Does your DSN point to the proper data base ?
5. If none of these suggestions work ... blame bill .. your ODBC manager seems to be corrupt
Originally posted by northfield Sid:
I have created an ODBC Data Source from windows/control panel/User DSN tab/MS Access Database <is high-lighted>/add <button>/Mircorsoft Access driver <selected>/finish <button>
A new dialog box opens,
Data Source name: Mydatabase
Description: contacts database
Select <buttton> navigate to where the database is, I have called it Mydatabase ...

But it still does not work???
 
northfield Sid
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it works:
getConnection("jdbc dbc:Mydatabase2");
was the problem,
In this case I will exonerate Bill, but not acquited for his other malfeasances.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!