SQLException 'general error' when using the JDBC-ODBC bridge
Hi folks,
There's a guy in my department who's trying to get to grips with JSPs and JDBC. He's written a test JSP accessing an Access database via the JDBC-ODBC bridge, but when he tries to run it, he gets an SQLException with the not very helpful error "general error".
The basic code is below:
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Conference");
Statement stmt = con.createStatement();
String familyName = request.getParameter("required_familyname");
String firstName = request.getParameter("required_firstname");
String organization = request.getParameter("organisation");
String position = request.getParameter("position");
String email = request.getParameter("required_email");
String queryUpdatePerson="insert into Person values ('ITIL2002', '" + email +"','foo','" + familyName +"','" + firstName +"','" + organization +"','" + position +"' )";
int rowsAffectedPerson = stmt.executeUpdate(queryUpdatePerson);
if (rowsAffectedPerson == 1)
{
%>
<h1>Thank youfor expressing interest</h1>
<%}
else
{
%>
<h1>Sorry,addition has failed.Please,try later</h1>
<%
}
stmt.close();
con.close();
%>
The exception gets thrown on the executeUpdate() line, but the query is definitely correct. We've copied the line and tried executing it directly on Access as a query and it works fine.
The database definitely exists as an ODBC data source (a simple JSP to print out the contents of a table proved that).
We're running Tomcat 3.1 on Windows NT 4 Server with SP6a applied. I've tried posting on the JavaServer Pages forum without any joy, can anyone help?
Thanks very much in advance,
Raj.
[2560 byte] By [
rajbhaskar] at [2007-9-26 3:18:14]

Just some more information. Some of the problems that I was having were down to network problems. I've now moved the database to a local disk and updated the ODBC datasource appropriately. Now when I run Tomcat from the command line, the code gets executed once and then the JVM crashes. I'm guessing that this is a Bridge problem, but is there any way around it, other than to stop using it?
I've used the Bridge in the past on a Win95 machine and although I wouldn't exactly call it stable, it never behaved like this. In the extreme case, would it be possible to run the database on a Win95 machine on the network and access it from the server like that?
thanks,
Raj.
>I'm guessing that this is a Bridge problem
And I would guess not. I have run a large scale 24x7 enterprise system on the bridge and never traced a single problem down to odbc or the bridge.
It is more likely an environment problem.
Maybe something you installed overwrote the ODBC driver with an older version.
The most likely reason for not finding a DSN is becuase the DSN was created in the user rather than system space. And the next most likely reason is because of permissions problems - which can be fixed using regedt32 (not the same as regedit.)
If it was me I would stop trying to do everything at once (Tomcat, service and jdbc.)
First get it to work from the command line. Then get it to work in Tomcat. Then get it to work as a service.
> Maybe something you installed overwrote the ODBC driver with an older version.
How would I re-install the driver? (Sorry for such a simple question, but I'm really just finding my feet in system administration -- I'm a programmer, not a sysadmin :o).
> The most likely reason for not finding a DSN is becuase the DSN was created in the user rather
> than system space.
Nope, it's certainly in the system space. I double checked that.
> And the next most likely reason is because of permissions problems - which can be fixed using
> regedt32 (not the same as regedit.)
Again, stupid question -- how?
Thanks,
Raj.