File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connect to Access from jsp

 
Steven Riche
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all:
I am new to jsp and i met a problem while connecting to Microsoft Access.
The following is the code:
<%@ page import="java.sql.*" %>
<html>
<body>
<%
String name=request.getParameter("name");
String balance=null;

if(name==null || "".equals(name)){
name="";
balance="";
}
else{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
out.println("load driver");
Connection dbc=DriverManager.getConnection("jdbc dbc:kkk");
out.println("get connected");
Statement s=dbc.createStatement();
ResultSet rs=s.executeQuery("select balance from tt where name='"+name+"'");
if (rs.next()){
balance=rs.getString(1);
}
rs.close();
s.close();
dbc.close();
}catch(Exception ex){
out.println(ex.getMessage());
}
}


%>
<form method="Get">
Name <input type="text" name="name" value=<%= name %>>
Balance <input type="text" name="balance" value=<%= balance %>>
<input type="submit" name="submit">
<input type="reset" name="reset">
</form>

</body>
</html>

The error message is:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
the datasoure "kkk" is in the ODBC pool and it tests well when I run a standalone program.
Any ideas?
 
Billybob Marshall
Ranch Hand
Posts: 202
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is "kkk" a 'system' DSN, or a 'user' or 'file' DSN? If not a 'system' DSN, when you start the J2EE server, is it running as the same user that owns the DSN?
 
Steven Riche
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
billbob, thanks.
cause I am using Tomcat 5, which start as Windows Service.
 
Billybob Marshall
Ranch Hand
Posts: 202
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Steven Riche:

...I am using Tomcat 5, which start as Windows Service.

That's probably the "SYSTEM" user. So your 'kkk' DSN needs to be defined as a 'system' DSN, not a user one.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic