Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

database not found java.sql.SQLException:[Microsoft][ODBC Driver Manag

Status
Not open for further replies.

CdnRebel

Programmer
Apr 5, 2003
39
CA
I defined a database using Access in my C drive. When I test my code the message I get is: database not found java.sql.SQL Exception:[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified. The code that seems to be causing the problem is somewhere in the following:
Code:
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class register3 extends HttpServlet {

protected void service(HttpServletRequest req, HttpServletResponse res)
						throws ServletException, IOException {
		PrintWriter out=res.getWriter();
		try{

		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

		Connection conn=DriverManager.getConnection("jdbc:odbc:CostConnection","","");
I have tested the above code using another database created in my C drive and there are no error messages. What does the error message mean? And what am I doing wrong? I am trying to work out the bugs in preparation for a school project. My java course is finished and the teacher has moved out of the country and the other students are unvailable for help.
 
Have you registered the database as a odbc data source? The other database might work if that has been registered.
 
I get the same error message if I connect the database from a servlet but if I try to access the same base with a regular java program it works
 
bigDaftie,
You may be right. It may be a step that I missed, but I'm not sure how to go about registering the database as an odbc data source. Can you walk me through it? I'm at destiny_mp@hotmail.com, if that helps.

Thanks
 
First of all sorry it's taken me so long to reply, you've probably sussed it out by now but if you haven't...
Secondly Jernunger, I'm not sure why that would be, it's not a spelling error?
Registering an ODBC data source is done by opening the Control Panel in windows, start then settings( I think it is under Administrative tools in XP and 2000), then open the ODBC data sources, selecting the user DSN tab, click Add, select Microsoft Access Driver, click finish. The Access Setup dialog should appear. Put the name of your database in for the Data Source Name eg CostConnection, click Select and navigate to where your database is, and is going to be when the application/servlet is run. When you've selected your database, click OK. You can set the username and password if you want by clicking Advanced. The ODBC data source administrator should now contain the name of your database. That's it.
Oh and if you any JDBC problems in general you could try posting on the Java forum as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top