Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Data source name not found and no default driver specified

843836Jan 11 2005 — edited Mar 25 2009
I am using MS Access 2003,J2SDK1.4.2,Tomcat Server 5.0.I wish to access the database through JSP.I have set the dsn name to"activeviewer".The database name is "ActiveViewer.mdb" which is stored in the webapps/application name directory.The following is my code for inserting data into the database:


<%@ page language="java" import="java.sql.*" errorPage="Error.jsp" %>
<html>
<head>
<title>
Add a Company
</title>
</head>
<body>
<%





Connection con=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String db = "jdbc:odbc:activeviewer={Microsoft Access Driver(*.mdb)};DBQ=C:\\Program Files\\Apache Software Foundation\\Tomcat 5.0\\webapps\\AdminPanel\\ActiveViewer.mdb";
con=DriverManager.getConnection(db);

String name=request.getParameter("name");
String city=request.getParameter("city");
String street=request.getParameter("street");
int zipcode=Integer.parseInt(request.getParameter("zipcode"));
String username=request.getParameter("username");
String password=request.getParameter("password");
int usernum=Integer.parseInt(request.getParameter("usernum"));
String billing=request.getParameter("billing");

String add="insert into company values(?,?,?,?,?,?,?,?);";
PreparedStatement ps=con.prepareStatement(add);

ps.setString(1,name);
ps.setString(2,city);
ps.setString(3,street);
ps.setInt(4,zipcode);
ps.setString(5,username);
ps.setString(6,password);
ps.setInt(7,usernum);
ps.setString(8,billing);
ps.executeUpdate();
}
catch (ClassNotFoundException e)
{
System.out.println("Could not locate driver.");
}
catch (SQLException e)
{
System.out.println("An SQL Exception has occured :: "+e);
}
finally
{
con.close();
}




%>
</body>
</html>

Iget the following error:
An SQL Exception has occured :: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Where am i going wrong?Can someone help me?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 22 2009
Added on Jan 11 2005
25 comments
4,560 views