I wrote a quick little jsp to access one of my db (a mysql)
<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.sql.*" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Test Connection</title> </head> <body> <% String name = ""; Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/dbName", "XXXX", "XXXXXX"); Statement stmt = conn.createStatement(); String query = "select * from friends where id='1'"; ResultSet rs = stmt.executeQuery(query); while(rs.next()){ name = rs.getString(3); } %> <%= name %> </body> </html> Worked like expected. I know this is not a java thread . . . but still trying to help since it is a time sensitive matter. Silly question, but are your jdbc drivers added to your library for the web app? I make this mistake ALL the time. Troy -----Original Message----- From: RAHUL RAJ <omrahulraj...@gmail.com> To: Tomcat Users List <users@tomcat.apache.org> Sent: Fri, Apr 15, 2011 1:59 pm Subject: Re: Working of Tomcat with MS Access ya...I did the same thing you told in mysql...but communications Exception occured.. This is like a small assignment that has to be submitted urgently..so I have to run away from the error! and tried with MS ACCESS. The jdbc program for access works perfect alone.. On Fri, Apr 15, 2011 at 11:19 PM, Troy <troylparr...@aol.com> wrote: > Raj, > > I think everyone is saying to take a look at this syntax: > > > >String url = "jdbc:odbc:rahul"; > > Connection con = DriverManager.getConnection(url, "", ""); > > > I know that when I make this type of simple jdbc connection in mysql the > syntax is: > > String url = "jdbc:mysql://localhost/dbName"; > Connection conn = DriverManager.getConnection(url, "", ""); > > Troy > > > > > > > > > > > -----Original Message----- > From: RAHUL RAJ <omrahulraj...@gmail.com> > To: Tomcat Users List <users@tomcat.apache.org> > Sent: Fri, Apr 15, 2011 1:31 pm > Subject: Re: Working of Tomcat with MS Access > > > I got communications exception when I did this with mysql...and no one > knows > > the reason perfectly...no response from mysql forum too... > > > > On Fri, Apr 15, 2011 at 9:08 PM, Troy <troylparr...@aol.com> wrote: > > > > > Raj; > > > > > > To all reading this response, this is my first response on this list so > if > > > I get it a little wrong have patience. > > > > > > You may want to look at the light weight RDBMS mysql. It is free, easily > > > installed and can be utilized with the companion Workbench to make > dealing > > > with the db very easy, a lot like the access interface. You will have > good > > > driver support from the java end as well and a lot of documentation and > > > tutorials to get you connected in your web app to your persistence layer. > > > > > > mysql.com > > > > > > Just my two cents and an attempt to give back a little to the community. > > > > > > Troy > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -----Original Message----- > > > From: RAHUL RAJ <omrahulraj...@gmail.com> > > > To: users <users@tomcat.apache.org> > > > Sent: Fri, Apr 15, 2011 6:05 am > > > Subject: Working of Tomcat with MS Access > > > > > > > > > Hello, > > > > > > I am working on building a jsp website with MS Access as > > > > > > database. When my login page is loaded on tomcat > > > > > > (localhost:8080/login.jsp), it shows the following error: > > > > > > > > > > > > java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source > > > > > > name not found and no default driver specified. > > > > > > > > > > > > The jdbc program alone is working perfectly, So There might not be > > > > > > problems due to Driver, Data source name, Database Tables or any > > > > > > other software version compatibilities. > > > > > > > > > > > > OS: Windows Vista Home Basic > > > > > > Tomcat Version: 5.5.x > > > > > > jdk version: 1.6 > > > > > > MS Access 2010 > > > > > > > > > > > > > > > > > > code is given below: > > > > > > > > > > > > <%@ page language="java" import="java.sql.*" %> > > > > > > <html> > > > > > > <body> > > > > > > <form method="post"> > > > > > > <p> Enter your username : <input type="text" name="username"/> </p> > > > > > > <p> Enter your password : <input type="text" name="password"/> </p> > > > > > > <input type="submit" value="Login"/> > > > > > > <% > > > > > > String usn = request.getParameter("username"); > > > > > > String pass = request.getParameter("password"); > > > > > > > > > > > > try{ > > > > > > Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); > > > > > > String url = "jdbc:odbc:rahul"; > > > > > > Connection con = DriverManager.getConnection(url, "", > ""); > > > > > > Statement s = con.createStatement(); > > > > > > > > > > > > ResultSet rs = s.executeQuery("select * from customers"); > > > > > > while(rs.next()) > > > > > > { > > > > > > String u = rs.getString(1); > > > > > > String p = rs.getString(2); > > > > > > if(usn.equals(u) && pass.equals(p)) > > > > > > { > > > > > > out.println("login successfull"); > > > > > > } > > > > > > else > > > > > > { > > > > > > out.println("login failed"); > > > > > > } > > > > > > } > > > > > > } > > > > > > > > > > > > catch(Exception e) > > > > > > { > > > > > > out.println("Error"+e); > > > > > > } > > > > > > > > > > > > %> > > > > > > </form> > > > > > > </body> > > > > > > </html> > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > > > > > > For additional commands, e-mail: users-h...@tomcat.apache.org > > > > > > > > > > > > > > > > > > > > > >