Re: DBConnectionProblems...

On Sun, 20 Jun 1999, Ragna-Lena&Dan wrote:

> On my machine I have MS Access97. When I fetch records from this DB
> using e.g. ColdFusion (www.allaire.com) and SQL, no problems at all.
> 
> When I use a servlet I get
> "SQLException caught: [Microsoft][ODBC Driver Manager] Invalid cursor state"
> Why?
> Here is relevant code in the Test.java:
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 

You should use the dedicated driver for your database, see
http://www.javasoft.com/products/jdbc/drivers.html
for a list of available drivers.

> 
> 
> // Get a Connection to the database
> 
> con = DriverManager.getConnection(
> 
> "jdbc:odbc:SQL_DREAM");

This URL looks strange, maybe that's because you try to access a local
database, but it looks strange to me ;)
> 
> 
> // Create a Statement object
> 
> stmt = con.createStatement();
> 
> 
> // Execute an SQL query, get a ResultSet
> 
> rs = stmt.executeQuery("SELECT PROCESSOR FROM ELVBERG_BOOKINGS WHERE ID = 1");
> 
> 
> // Display the result set as a list
> 
> out.println("<HTML><HEAD><TITLE>Test</TITLE></HEAD>");
> 
> out.println("<BODY>");
> 
> out.println(rs.getString("processor")); 
> 
> out.println("</BODY></HTML>");
> 
> -dan
> 
> 

      /\          - Yves Lafon - World Wide Web Consortium - 
  /\ /  \        Architecture Domain - Jigsaw Activity Leader
 /  \    \/\    
/    \   /  \   http://www.w3.org/People/Lafon - ylafon@w3.org    

Received on Monday, 21 June 1999 08:19:26 UTC