note that you must use

if (rs.next())

or 

while (rs.next())

before accessing any results in order to position the pointer to the
first record in the result set.

HTH

Alan

> 
> I managed to create the connection, statement and the 
> resultset, the problem
> is when I try to get the data:
> 
> try
> {
>   Connection con = broker.getConnection();  //using the 
> DBConnectionBroker
> pool
>   Statement stmt = con.createStatement();
>   ResultSet rs = stmt.executeQuery("SELECT MAX(id) AS 'id' 
> FROM table");
> 
>    if (rs.getString(1) != null)  // THIS IS THE PROBLEMATIC PART
>       id = String.valueOf(rs.getInt(1) + 1);  // assign an id 
> to the user
>    else
>       id = "1";
> }
> 
> note that I have records in the table so it does fetch results.
> 
> Thanks,
> David.
> 
> 
> ----- Original Message -----
> From: "Richard Downey" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, February 14, 2001 3:59 PM
> Subject: RE: connecting to MS-SQL
> 
> 
> > At what point does it raise that message ? Have you 
> connected OK to the
> > Database ? got a Recordset etc.  ? The JDBC-ODBC in SDK 1.3 
> certainly
> works
> > with SQL 7 and is very Quick.
> >
> > -----Original Message-----
> > From: David Treves [mailto:[EMAIL PROTECTED]]
> > Sent: 14 February 2001 13:38
> > To: mailing list tomcat-users
> > Subject: 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: [EMAIL PROTECTED]
> > For additional commands, email: [EMAIL PROTECTED]
> >
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, email: [EMAIL PROTECTED]
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to