tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frank Mau <...@stardivision.de>
Subject Re: connecting to MS-SQL
Date Wed, 14 Feb 2001 14:51:39 GMT
Hi, 
I think you should try this code-snippet:

...
Connection con = null;
try {
  // get data from database
  con = DriverManager.getConnection( ... ); // replace with your 
DB-connector

  Statement stmt = con.createStatement();
  ResultSet rs = stmt.executeQuery( "put your SQL-Statement here" );
  if ( null != rs  ) {
     while( rs.next() ) {
       ... (get data with rs.getString() etc.)
     }
     rs.close();
  }
  rs = null;
  stmt.close();
  stmt = null;
} catch( Exception e ) {
  ... // some exception handling here		
} finally {
  // don't forget to close the connection !!
  try { con.close(); con = null; } catch( Exception e ) {}
}
...

Bye
Frank


>>>>>>>>>>>>>>>>>> Urspr√ľngliche Nachricht
<<<<<<<<<<<<<<<<<<

Am 14.02.01, 14:38:10, schrieb "David Treves" <davidt@macam98.ac.il> zum 
Thema connecting to MS-SQL:


> Hi,

>     I am trying to connect to a MS-SQL 7 database. I manage to create all
> the necessary object, but when I execute the servlet I get the following
> error:

> [Microsoft][ODBC Driver Manager] Invalid cursor state

> I use JdbcOdbc driver supplied with SDK 1.3

> Any idea?

> David Treves


> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-user-help@jakarta.apache.org

Mime
View raw message