Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-22-2009, 04:44 AM
Member
 
Join Date: Apr 2009
Posts: 7
Rep Power: 0
hadesflames is on a distinguished road
Default JDBC data retrieval with MySQL
Ok I have a server with 5+ columns and 5+ rows (the actual amount doesn't matter)

I have the data from column 2, row 4 stored in a variable, how do i then store the data in column 4 row 4 in another variable?

I don't know any MySQL syntax, nor how to use it in java much so if someone could show me a coded example i'd really appreciate it.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 04-22-2009, 06:38 AM
Senior Member
 
Join Date: Dec 2008
Location: Hong Kong
Posts: 473
Rep Power: 2
mtyoung is on a distinguished road
Default
Quote:
server with 5+ columns and 5+ rows
table or server?

Quote:
I have the data from column 2, row 4 stored in a variable, how do i then store the data in column 4 row 4 in another variable?
is that means you want to get data at row4 column 4 from the databases table?

read MySQL :: MySQL 5.0 Reference Manual :: 12.2.8 SELECT Syntax
and Trail: JDBC(TM) Database Access (The Java™ Tutorials)

it is difficult to get data by rowX, columnX
you should use Select select_expr(may be entity name) from table_name where conditions
why you wants data at row4 column 4? it may be data in row4 column1, column 2 etc show that data you want in row4
use where where_condition to get row4

Last edited by mtyoung; 04-22-2009 at 06:44 AM.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-22-2009, 07:58 AM
Senior Member
 
Join Date: Nov 2008
Posts: 275
Rep Power: 2
neilcoffey is on a distinguished road
Default
In case it helps as well, a page of mine on reading data from a ResultSet.

The usual procedure is that you structure your query to retrieve more or less the subset of rows that you want, then if necessary, call ResultSet.next() to skip down to the one you want within that subset.
__________________
Neil Coffey
Javamex - Java tutorials and performance info
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-22-2009, 02:05 PM
Member
 
Join Date: Apr 2009
Posts: 7
Rep Power: 0
hadesflames is on a distinguished road
Default
I am talking about a table that has a value in column 2 row 4 now i want to get a value from a different column, but of the SAME row as the first one (4) the actual numbers are examples and do not matter. I am doing a program where knowing a "username" I would be able to retrieve user data.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-22-2009, 05:38 PM
Senior Member
 
Join Date: Nov 2008
Posts: 275
Rep Power: 2
neilcoffey is on a distinguished road
Default
In that case, I still don't understand why you care about the row numbers especially. You'd do a query, e.g.

Code:
SELECT Id, FirstName, Surname, ... FROM Users WHERE username = '....';
and then the single row returned by this query would be the one you want.
__________________
Neil Coffey
Javamex - Java tutorials and performance info
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-23-2009, 05:38 AM
Senior Member
 
Join Date: Dec 2008
Location: Hong Kong
Posts: 473
Rep Power: 2
mtyoung is on a distinguished road
Default
if you know the data type, use resultSet.getXXX(4)
XXX can String, Int etc
read ResultSet (Java Platform SE 6)
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ODBC versus SQLSERVER data retrieval issues, known ??? BobZ_Annapolis Database 1 02-23-2009 07:48 PM
MySQL/JDBC Mysql query output thelinuxguy Advanced Java 4 02-13-2009 02:57 AM
Java JDBC/MySQL appropriate Syntax thelinuxguy Advanced Java 7 02-10-2009 08:57 PM
help ... JDBC or PHP/MySQL bluebarca Advanced Java 1 11-16-2007 11:05 AM
ClassNotFoundException com.mysql.jdbc.Driver Heather Database 2 06-30-2007 03:42 PM


All times are GMT +2. The time now is 02:50 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org