Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java Databases
|
Java Databases Discussion specific to working with Java Databases. For other Java topics, please see related Java forums. For database discussions not specific to Java, please see the Database category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 26th, 2004, 04:37 AM
Registered User
 
Join Date: Jan 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default JAVA Web Database problem

Can anyone help me find out how to solve this problem ?
I created a JAVA Web Database program, but there is a problem with exception report
"The server encountered an internal error () that prevented it from fulfilling this request"
the root cause is
"javax.servlet.ServletException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"

The strange is that when I try creating a JAVA program running on MS DOS prompt by using the same code for connection. It's working properly.

Can anyone suggest me what I may get mistake ? Thank you so much.

 
Old January 26th, 2004, 05:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How are you loading the database driver? It could possibly be a class path problem. Post the segment of code you are using.

Cheers

Martyn
 
Old January 26th, 2004, 09:22 PM
Registered User
 
Join Date: Jan 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Martyn,
 Here is the code. I have installed j2sdk on my server and set MS-ODBC for j3pmarket database.

<html>
<head>
<title>j3pMarket Departments </title>
</head>
<%@ page language="java" import="java.sql.*" %>
<body bgcolor=cyan>

<br>

<center><table rows=1 border=1>
    <tr><td><b>j3pMarket Departments</b></td></tr>
 </table></center>
<%
 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

 Connection cn = DriverManager.getConnection("jdbc:odbc:j3pmarket", "", "");

 Statement stmt = cn.createStatement();

 ResultSet rs = stmt.executeQuery("Select * From Employee, Department, City Where " +
        "(Employee.Dept=Department.idDepartment And Employee.CityOfResidence=City.idCity)" +
        " Order By Department.idDepartment, idEmployee");

  int curDeptID = 0;
  int deptSecretary = 0;
  String secretaryMark = "";

  if (rs != null)
  {
        while (rs.next())
        {
          int deptID = rs.getInt("idDepartment");

           if (deptID != curDeptID)
           {
             if (curDeptID != 0)
             {
%>
               </table>
               </center>
<%
              }
              String deptName = rs.getString("name");
              deptSecretary = rs.getInt("secretary");
              String deptPhone = rs.getString("phone");
 %>
             <center>
            <table border="2" width="600" cols=6 bgcolor=#dddd00>
            <tr>

                <td bgcolor="#000099" border="0" colspan=6><p align="center">

                <b> <%= deptName %> Department </td>
            </tr>
            <tr>
                <td bgcolor="#000099" border="0" colspan=6>

                 Direct Phone: <%= deptPhone %>, secretary marked with '*' below</b></td>
            </tr>
            <tr>
                   <td><b>ID</b></td>
                   <td><b>First Name</b></td>
                   <td><b>Last Name</b></td>
                   <td><b>Employee Date</b></td>
                   <td><b>City</b></td>
                   <td><b>Email Address</b></td>
             </tr>
<%
               curDeptID = deptID;
           }
           int empID = rs.getInt("idEmployee");
           if (empID == deptSecretary)
                secretaryMark = "*";
           else
                secretaryMark = "";
           String first = rs.getString("FirstName");
           String last = rs.getString("LastName");
           String empDate = rs.getString("EmpDate");
           String city = rs.getString("cityName");
           String email = rs.getString("EmailAddr");

%>
<tr>
           <td><%= empID %><%= secretaryMark %></td>

           <td><%= first %></td>
           <td><%= last %></td>
           <td><%= empDate %></td>
           <td><%= city %></td>
           <td><%= email %></td>
</tr>
<br>
<%
       }
   }
  stmt.close();
  cn.close();
%>
</table>
</center>
<br>
</body>
</html>

<Style type="text/css">
A { Color: #0000FF;Text-Decoration: underline }
A:Hover { Color: #FF0000;Text-Decoration: underline}
</Style>


 
Old January 27th, 2004, 03:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have you set the JAVA_HOME variable. ie JAVA_HOME=C:\jdk1.4

Your classpath should be something like this: CLASSPATH=.;C:\jdk1.4jre\lib\rt.jar;

Is your DSN a System DSN? Check it by using it to import data into Excel.

Let me know how you get on, also I'm assuming thst you are using Access and Tomcat. Is this correct? If not let me know as I have other ideas.

Also, if you wrap a try/catch block around your code you will be able to trap the specific error

Cheers

Martyn





Similar Threads
Thread Thread Starter Forum Replies Last Post
java axis web service deb_net J2EE 2 June 12th, 2007 12:40 AM
database problem[java] sunanda_chowdary Java Databases 0 February 21st, 2006 04:00 AM
Professional Java Web Services koukane J2EE 0 December 8th, 2004 02:38 PM
What is this => Java Web Start hlchuah77 Java GUI 2 August 24th, 2004 09:37 AM
Database access from java, INSERT query problem nitusincog BOOK: Beginning Java 2 1 July 21st, 2003 10:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.