aspose file tools*
The moose likes JDBC and the fly likes problem connecting to access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "problem connecting to access" Watch "problem connecting to access" New topic
Author

problem connecting to access

panindra nath
Greenhorn

Joined: Jan 23, 2008
Posts: 6
HI,this my servlet code for retreiving contents from the database using ms-access......whenever i launch browser and type in the URL it throws an error


java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

so what should be the remedy to this problem?

thanks...




import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class test extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{

response.setContentType("text/html");
PrintWriter pw = response.getWriter();
Connection connection=null;


try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection = DriverManager.getConnection("jdbcdbc:db2");
Statement st = connection.createStatement();
ResultSet rs = st.executeQuery("select * from emp");
while(rs.next())
{
pw.println(rs.getString(1));
pw.println(rs.getString(2));
pw.println(rs.getString(3));
pw.println();
}
}
catch (Exception e)
{
pw.println(e);
}
}
}
Herman Schelti
Ranch Hand

Joined: Jul 17, 2006
Posts: 387
hi,

did you define a datasource (see settings - control panel - administrative tools).

Don't understabd why you want to call it db2.

Herman
panindra nath
Greenhorn

Joined: Jan 23, 2008
Posts: 6
YES i did,i selected ms access driver(*.mdb)
User data source as db2
database c:\db2.mdb;

The statement /*connection = DriverManager.getConnection("jdbcdbc:db2");*/ is throwing the exception.... so i think there s something wrong with the path "jdbcdbc:db2".Can you please send me correct path ? Do i need to install any driver for connecting servlet to ms-access?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19557
    
  16

Did you create the DSN as a user DSN or a system DSN?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Hareendranath Babu Kotha
Ranch Hand

Joined: May 22, 2006
Posts: 40
Hi ,

I also got the same problem, but it got resolved once i selected System DSN instead of User DSN. So, trying with System DSN will resolve your problem.


Hari.K,<br />+919886082889
kkk guptha
Greenhorn

Joined: Nov 17, 2007
Posts: 3
For MS-Access connection,
-- First you have to register DSN and make username and password there.
-- After that link the database of your application to that DSN.
-- In the connection statement, mention as
connection myconn = DriverManager.getConnection("jdbcdbcSNname","username","password");



---KKK Guptha
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem connecting to access
 
Similar Threads
connection error
servlet-jdbc - internal servlet error (error:500)
how to delete row in database?, pls help in my coding
servlet program , sql error in coding, helpppp
Running Servlets on Linux