| 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("jdbc dbc: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("jdbc dbc:db2");*/ is throwing the exception.... so i think there s something wrong with the path "jdbc dbc: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: 19216
|
|
|
Did you create the DSN as a user DSN or a system DSN?
|
SCJP 1.4 - SCJP 6 - SCWCD 5
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("jdbc dbc SNname","username","password"); ---KKK Guptha
|
 |
 |
|
|
subject: problem connecting to access
|
|
|