RE: resultset Question

2001-05-22 Thread Warren Crossing

did you use rs.next(); ?? you have to do this first to move the cursor to
the first record.. makes sense.

regards,

warren. 

-Original Message-
From: Manish [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 22 May 2001 9:00 AM
To: [EMAIL PROTECTED]
Subject: Re: resultset Question


Kevin Fonner wrote:

 I want to grab just the first record in a Query of my database.  I 
 thought that this would be pretty simple???
 
 Acording to my books they said that after executing...
 
 /resultSet = statement.executeQuery(SELECT * FROM userfolders WHERE 
 username=\' + userName + \');/
 
 That resultset would contain the first record.  But I can't seem to 
 grab the data. Below is a sample of my code that I think pertains to 
 my problem.  If anybody has any ideas I would appreciate them
 
 resultSet = statement.executeQuery(SELECT * FROM userfolders WHERE 
 username=\' + userName + \');
dFolder = resultSet.getString(folder);
dModule = resultSet.getString(dmod);
dModulePath = resultSet.getString(dmod_path);
 
  
 
 Thanks,
 
 Kevin
 
Kevin,

 resultset would contain the first  record would contain the first 
record is not true... you have to do

while (rs.next()) {

//do Something

}

This might help

Thanks

-- 
Manish Poddar

Software Engineer
Paycom.net



Re: resultset Question

2001-05-22 Thread Guido Medina

Hi,

  I think that if you want only the first record you should put if
(rs.next()) statement instead of while.., it is only one condition, not a
cycle...

statement = statement or {statement,}

  Second, you don't need rs.beforeFirst(); 'cause when you make the query
automatically is before the first record and when you call rs.next() will
put the pointer in the first record and at the same time is returning true
or false in case that exists a first record or not...

Regards...

Guido.

- Original Message -
From: Warren Crossing [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, May 22, 2001 3:41 AM
Subject: RE: resultset Question


 did you use rs.next(); ?? you have to do this first to move the cursor to
 the first record.. makes sense.

 regards,

 warren.

 -Original Message-
 From: Manish [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, 22 May 2001 9:00 AM
 To: [EMAIL PROTECTED]
 Subject: Re: resultset Question


 Kevin Fonner wrote:

  I want to grab just the first record in a Query of my database.  I
  thought that this would be pretty simple???
 
  Acording to my books they said that after executing...
 
  /resultSet = statement.executeQuery(SELECT * FROM userfolders WHERE
  username=\' + userName + \');/
 
  That resultset would contain the first record.  But I can't seem to
  grab the data. Below is a sample of my code that I think pertains to
  my problem.  If anybody has any ideas I would appreciate them
 
  resultSet = statement.executeQuery(SELECT * FROM userfolders WHERE
  username=\' + userName + \');
 dFolder = resultSet.getString(folder);
 dModule = resultSet.getString(dmod);
 dModulePath = resultSet.getString(dmod_path);
 
 
 
  Thanks,
 
  Kevin
 
 Kevin,

  resultset would contain the first  record would contain the first
 record is not true... you have to do

 while (rs.next()) {

 //do Something

 }

 This might help

 Thanks

 --
 Manish Poddar

 Software Engineer
 Paycom.net





Re: resultset Question

2001-05-22 Thread Kaneda K

I like to add (juste in case) that there was a bug in MySQL driver 2.0.1 or 
2.0.2 where resulset where starting at row 1 instead of 0.

At 03:52 22/05/2001 -0400, you wrote:
Hi,

   I think that if you want only the first record you should put if
(rs.next()) statement instead of while.., it is only one condition, not a
cycle...

statement = statement or {statement,}

   Second, you don't need rs.beforeFirst(); 'cause when you make the query
automatically is before the first record and when you call rs.next() will
put the pointer in the first record and at the same time is returning true
or false in case that exists a first record or not...

Regards...

Guido.

- Original Message -
From: Warren Crossing [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, May 22, 2001 3:41 AM
Subject: RE: resultset Question


  did you use rs.next(); ?? you have to do this first to move the cursor to
  the first record.. makes sense.
 
  regards,
 
  warren.
 
  -Original Message-
  From: Manish [mailto:[EMAIL PROTECTED]]
  Sent: Tuesday, 22 May 2001 9:00 AM
  To: [EMAIL PROTECTED]
  Subject: Re: resultset Question
 
 
  Kevin Fonner wrote:
 
   I want to grab just the first record in a Query of my database.  I
   thought that this would be pretty simple???
  
   Acording to my books they said that after executing...
  
   /resultSet = statement.executeQuery(SELECT * FROM userfolders WHERE
   username=\' + userName + \');/
  
   That resultset would contain the first record.  But I can't seem to
   grab the data. Below is a sample of my code that I think pertains to
   my problem.  If anybody has any ideas I would appreciate them
  
   resultSet = statement.executeQuery(SELECT * FROM userfolders WHERE
   username=\' + userName + \');
  dFolder = resultSet.getString(folder);
  dModule = resultSet.getString(dmod);
  dModulePath = resultSet.getString(dmod_path);
  
  
  
   Thanks,
  
   Kevin
  
  Kevin,
 
   resultset would contain the first  record would contain the first
  record is not true... you have to do
 
  while (rs.next()) {
 
  //do Something
 
  }
 
  This might help
 
  Thanks
 
  --
  Manish Poddar
 
  Software Engineer
  Paycom.net
 




Re: resultset Question

2001-05-21 Thread Manish

Kevin Fonner wrote:

 I want to grab just the first record in a Query of my database.  I 
 thought that this would be pretty simple???
 
 Acording to my books they said that after executing...
 
 /resultSet = statement.executeQuery(SELECT * FROM userfolders WHERE 
 username=\' + userName + \');/
 
 That resultset would contain the first record.  But I can't seem to 
 grab the data. Below is a sample of my code that I think pertains to 
 my problem.  If anybody has any ideas I would appreciate them
 
 resultSet = statement.executeQuery(SELECT * FROM userfolders WHERE 
 username=\' + userName + \');
dFolder = resultSet.getString(folder);
dModule = resultSet.getString(dmod);
dModulePath = resultSet.getString(dmod_path);
 
  
 
 Thanks,
 
 Kevin
 
Kevin,

 resultset would contain the first  record would contain the first 
record is not true... you have to do

while (rs.next()) {

//do Something

}

This might help

Thanks

-- 
Manish Poddar

Software Engineer
Paycom.net




resultset Question

2001-05-14 Thread Kevin Fonner



I want to grab just the first record in a Query of 
my database. I thought that this would be pretty simple???
Acording to my books they said that after 
executing...
resultSet = statement.executeQuery("SELECT * 
FROM userfolders WHERE username=\'" + userName + "\'");
That resultset would contain the first 
record. But I can't seem to grab the data. Below is a sample of my code 
that I think pertains to my problem. If anybody has any ideas I would 
appreciate them
resultSet = statement.executeQuery("SELECT * FROM 
userfolders WHERE username=\'" + userName + "\'");dFolder 
= resultSet.getString("folder");dModule = 
resultSet.getString("dmod");dModulePath = 
resultSet.getString("dmod_path");

Thanks,
Kevin


RE: resultset Question

2001-05-14 Thread Jann VanOver



So 
what is happening? Do you get anything? Do you get an error? 


I have 
found that with some JDBC drivers you are required to get the columns in the 
same order they appear in the select statement. So changing your "select 
*" to "select folder,dmod,dmod_path" would fix it if this is the 
problem.

Oh -- 
wait -- I see it now! You need to do a resultSet.next() before you can 
.getString() ... try that!

  -Original Message-From: Kevin Fonner 
  [mailto:[EMAIL PROTECTED]]Sent: Monday, May 14, 2001 2:16 
  PMTo: [EMAIL PROTECTED]Subject: resultset 
  Question
  I want to grab just the first record in a Query 
  of my database. I thought that this would be pretty 
  simple???
  Acording to my books they said that after 
  executing...
  resultSet = statement.executeQuery("SELECT * 
  FROM userfolders WHERE username=\'" + userName + "\'");
  That resultset would contain the first 
  record. But I can't seem to grab the data. Below is a sample of my code 
  that I think pertains to my problem. If anybody has any ideas I would 
  appreciate them
  resultSet = statement.executeQuery("SELECT * FROM 
  userfolders WHERE username=\'" + userName + 
  "\'");dFolder = 
  resultSet.getString("folder");dModule = 
  resultSet.getString("dmod");dModulePath = 
  resultSet.getString("dmod_path");
  
  Thanks,
  Kevin


Re: resultset Question

2001-05-14 Thread Richard Draucker



On Mon, 14 May 2001 17:16:24 -0400, Kevin Fonner
[EMAIL PROTECTED] wrote:
I want to grab just the first record in a Query of my database.  I
thought that this would be pretty simple???
Acording to my books they said that after executing...
Try...
resultSet rs = statement.executeQuery(select * from table where
column=data);
rs.next()  // this outta do it for ya, each rs.next() advances the
cursor one row.
dFolder = rs.getString(1);  // avoid using column names


resultSet = statement.executeQuery(SELECT * FROM userfolders WHERE
username=\' + userName + \');
That resultset would contain the first record.  But I can't seem to
grab the data. Below is a sample of my code that I think pertains to my
problem.  If anybody has any ideas I would appreciate them

resultSet = statement.executeQuery(SELECT * FROM userfolders WHERE
username=\' + userName + \');
   dFolder = resultSet.getString(folder);
   dModule = resultSet.getString(dmod);
   dModulePath = resultSet.getString(dmod_path);

Thanks,
Kevin


Richard Draucker
[EMAIL PROTECTED]
Protected-Data.Com
Remote Data Support For Web Developers




RE: resultset Question

2001-05-14 Thread Duck-Jin Chun



Kevin,

There 
are 2 problems with your message. First, this question is extremely off 
topic for this mailing list. Second, you do not say what kind of errors 
and/or results you get by executing your current code. You simply say you 
"can't seem to grab the data". Not very helpful.

But 
since I hate it when people just scream "off topic"... Take a look at the api 
documentation for java.sql.ResultSet.next(). 
The next() method needs to be called 
before you start calling the get*() 
methods.

-Duck

  -Original Message-From: Kevin Fonner 
  [mailto:[EMAIL PROTECTED]]Sent: Monday, May 14, 2001 5:16 
  PMTo: [EMAIL PROTECTED]Subject: resultset 
  Question
  I want to grab just the first record in a Query 
  of my database. I thought that this would be pretty 
  simple???
  Acording to my books they said that after 
  executing...
  resultSet = statement.executeQuery("SELECT * 
  FROM userfolders WHERE username=\'" + userName + "\'");
  That resultset would contain the first 
  record. But I can't seem to grab the data. Below is a sample of my code 
  that I think pertains to my problem. If anybody has any ideas I would 
  appreciate them
  resultSet = statement.executeQuery("SELECT * FROM 
  userfolders WHERE username=\'" + userName + 
  "\'");dFolder = 
  resultSet.getString("folder");dModule = 
  resultSet.getString("dmod");dModulePath = 
  resultSet.getString("dmod_path");
  
  Thanks,
  Kevin


Re: resultset Question

2001-05-14 Thread Kevin Fonner



Duck,
My apoligies. I have been spending the last 
couple weeks learning tomcat and servlet type stuff and have been asking about 
any confusing things I come across with this on this list. Even though I'm 
working on a servlet I suppose that question could have been better directed at 
a java database kind of list.
Thanks for the tip,
Kevin

  - Original Message - 
  From: 
  Duck-Jin 
  Chun 
  To: '[EMAIL PROTECTED]' 
  
  Sent: Monday, May 14, 2001 5:54 PM
  Subject: RE: resultset Question
  
  Kevin,
  
  There are 2 problems with your message. First, 
  this question is extremely off topic for this mailing list. Second, you 
  do not say what kind of errors and/or results you get by executing your 
  current code. You simply say you "can't seem to grab the data". 
  Not very helpful.
  
  But 
  since I hate it when people just scream "off topic"... Take a look at the api 
  documentation for java.sql.ResultSet.next(). 
  The next() method needs to be called 
  before you start calling the get*() 
  methods.
  
  -Duck
  
-Original Message-From: Kevin Fonner 
[mailto:[EMAIL PROTECTED]]Sent: Monday, May 14, 2001 5:16 
PMTo: [EMAIL PROTECTED]Subject: resultset 
Question
I want to grab just the first record in a Query 
of my database. I thought that this would be pretty 
simple???
Acording to my books they said that after 
executing...
resultSet = statement.executeQuery("SELECT 
* FROM userfolders WHERE username=\'" + userName + "\'");
That resultset would contain the first 
record. But I can't seem to grab the data. Below is a sample of my 
code that I think pertains to my problem. If anybody has any ideas I 
would appreciate them
resultSet = statement.executeQuery("SELECT * 
FROM userfolders WHERE username=\'" + userName + 
"\'");dFolder = 
resultSet.getString("folder");dModule = 
resultSet.getString("dmod");dModulePath = 
resultSet.getString("dmod_path");

Thanks,
Kevin


RE: resultset Question

2001-05-14 Thread Midian - Jakarta List



Check 
out the sun JDBC tutorial at : http://java.sun.com/docs/books/tutorial/jdbc/index.html. 
That tutorial really is a great place to start when you are learning JDBC. 


- 
Midian

  -Original Message-From: Kevin Fonner 
  [mailto:[EMAIL PROTECTED]]Sent: Monday, May 14, 2001 2:16 
  PMTo: [EMAIL PROTECTED]Subject: resultset 
  Question
  I want to grab just the first record in a Query 
  of my database. I thought that this would be pretty 
  simple???
  Acording to my books they said that after 
  executing...
  resultSet = statement.executeQuery("SELECT * 
  FROM userfolders WHERE username=\'" + userName + "\'");
  That resultset would contain the first 
  record. But I can't seem to grab the data. Below is a sample of my code 
  that I think pertains to my problem. If anybody has any ideas I would 
  appreciate them
  resultSet = statement.executeQuery("SELECT * FROM 
  userfolders WHERE username=\'" + userName + 
  "\'");dFolder = 
  resultSet.getString("folder");dModule = 
  resultSet.getString("dmod");dModulePath = 
  resultSet.getString("dmod_path");
  
  Thanks,
  Kevin