Hi,

to get the count:

String query = "SELECT count(*) FROM EMPLOYEE where
FIRST_NAME='first'";
        while (rs.next())
        {
          int i = rs.getInt( 1 );
          System.out.println( "i: " + i );
        ...

ron

--- Tarik Makota <[EMAIL PROTECTED]>
wrote:
> OK
> I found a problem,
>
> It seams that my ODBC version somehow has a glitch
> so i need to update it.
> My Sybase ASA connection via JDBC:ODBC is OK but
> Microsoft based databases
> are failing.
> However is there a wayy in Jav ato do something
> like:
>
> String validate = "SELECT count(*) FROM security
> WHERE username = '" +
> userName +"'"
> Statement stmt = con.createStatement();
> integer CountIt= stmt.execute(validate);
>
> or do i have to use getUpdateCount()  and if Yes
>
> would this be correct syntax?
>
> String validate = "SELECT count(*) FROM security
> WHERE username = '" +
> userName +"'"
> Statement stmt = con.createStatement();
> ResultSet rs = stmt.execute(validate);
> integer count = stmt.getUpdateCount();
> if (count > 0) {
>     Yipppppiiiii.
> else
>     buuu--hhhhhh
> end if
>
>
>
>
>
> Thanks guys.
>
>
> ----- Original Message -----
> From: Tarik Makota <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, August 09, 2000 2:06 PM
> Subject: Re: DB Access problem
>
>
> > I changed odbc from CoffeePot to NorthWind (MSSQL
> 7.0)
> > I have DSN under System and can access it from
> PowerBuilder so it works.
> >
> > This is the error i get when i run .jsp
> >
> > java.sql.SQLException: [Microsoft][ODBC SQL Server
> Driver]Invalid
> Descriptor
> > Index
> >
> >
> >
> > ----- Original Message -----
> > From: Matthews,Paul <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, August 09, 2000 12:45 PM
> > Subject: Re: DB Access problem
> >
> >
> > > silly question- should that be 'CoffeePot' in
> the url?
> > >
> > > also call getConnection(url); rather than
> passing empty
> username/password
> > >
> > > regards, paul
> > >
> > > > -----Original Message-----
> > > > From: Tarik Makota
> [mailto:[EMAIL PROTECTED]]
> > > > Sent: 09 August 2000 17:37
> > > > To: [EMAIL PROTECTED]
> > > > Subject: DB Access problem
> > > >
> > > >
> > > > This is my acctual bean that is supposetly to
> connect to DB:
> > > > I put the 'markers' so that i know where it
> stops.
> > > >
> > > > As soon as it hits Connection conn = ... it
> stops
> > > > because in my jsp page print the propert
> userName
> > > > so that i know wher do i get stuck.
> > > > JSP page is displayed without any errors
> > > >
> > > >
> > > > My DSN  is ok because i have tried User and
> System.
> > > >
> > > >
> > > >
> > > >
>
----------------------------------------------------------
> > > > package foo;
> > > > import java.util.*;
> > > > import java.sql.*;
> > > > import java.net.URL.*;
> > > >
> > > >
> > > > public class DBLoginBean6{
> > > >  private boolean isValid = false;
> > > >  private String userName;
> > > >  private String userPassword;
> > > >
> > > >  public DBLoginBean6() {
> > > >      userName="Initalized";
> > > >      userPassword="";
> > > >      String url = "jdbc:odbc:CofeePot";
> > > >      String query = "SELECT * FROM EMPLOYEES";
> > > >      String firstName;
> > > >      String lastName;
> > > >      boolean more;
> > > >      try
> > > >      {
> > > >   userName="First Try";
> > > >         try{
> > > >
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> > > >   }
> > > >   catch (java.lang.ClassNotFoundException ex)
> > > >        {
> > > >           ex.printStackTrace();
> > > >       }
> > > >       userName=" connection begin";
> > > >         Connection con =
> DriverManager.getConnection(url,"","");
> > > >         userName="I connected";
> > > >         Statement stmt =
> con.createStatement();
> > > >   userName="i created statement";
> > > >         ResultSet rs =
> stmt.executeQuery(query);
> > > >         userName="i executed statement";
> > > >         while (more = rs.next())
> > > >         {
> > > >              firstName =
> rs.getString("FIRSTNAME");
> > > >              lastName =
> rs.getString("LASTNAME");
> > > >              System.out.println( firstName + "
> " + lastName);
> > > >              userName = "I was executed";
> > > >         }
> > > >   userName="I did while";
> > > >         rs.close();
> > > >         stmt.close();
> > > >         con.close();
> > > >         userName="And i ewxited";
> > > >      }
> > > >      catch (SQLException ex)
> > > >   {
> > > >       ex.printStackTrace();
> > > >      }
> > > >
> > > >
> > > >
> > > >  }
> > > >
> > > >  public String getuserName() {
> > > >        return userName;
> > > >  }
> > > >  public String getuserPassword() {
> > > >        return "I am user Password";
> > > >  }
> > > >
> > > >  }
> > > > ----------------------------
> > > >
> > > >
>
==============================================================
> > > > =============
> > > > To unsubscribe: mailto [EMAIL PROTECTED]
> with body:
> > > > "signoff JSP-INTEREST".
> > > > Some relevant FAQs on JSP/Servlets can be
> found at:
> > > >
> > >  http://java.sun.com/products/jsp/faq.html
> > >  http://www.esperanto.org.nz/jsp/jspfaq.html
> > >
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > >
>
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> > >
> > >
> >
>
===========================================================================
> > > To unsubscribe: mailto [EMAIL PROTECTED]
> with body: "signoff
> > JSP-INTEREST".
> > > Some relevant FAQs on JSP/Servlets can be found
> at:
> > >
> > >  http://java.sun.com/products/jsp/faq.html
> > >  http://www.esperanto.org.nz/jsp/jspfaq.html
> > >
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > >
>
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> > >
> >
> >
>
===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with
> body: "signoff
> JSP-INTEREST".
> > Some relevant FAQs on JSP/Servlets can be found
> at:
> >
> >  http://java.sun.com/products/jsp/faq.html
> >  http://www.esperanto.org.nz/jsp/jspfaq.html
> >
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> >
>
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with
> body: "signoff JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets


__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to