• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dont know much sql in java...

 
Bob Thompson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've had an ongoing thread about making an administrator application in java that will be able to display update and delete table data. My question is:

Where would i find how to make this same line in java:

code:
--------------------------------------------------------------------------------

$result = mysql_query($sql, $dbase) or die(mysql_error());

--------------------------------------------------------------------------------


thats from a php file i made. It also has:

code:
--------------------------------------------------------------------------------

$dbase = "riverview";@$sql = "SELECT * FROM riverview WHERE month = ".$month." AND year=".$year;

--------------------------------------------------------------------------------


then there's an array in a while statement that fetches all of the data from the field specefied:

code:
--------------------------------------------------------------------------------

while ($TEMPArray[$tempi] = mysql_fetch_array($result)){ $tempi=$tempi+1; }

--------------------------------------------------------------------------------



So what i'm trying to do it get into an existing table, fetch everything on that table thats in the specified field, then display it somehow.


My old threads here if you wanted to see anything else we went through.

http://www.coderanch.com/t/341155/GUI/java/Visibility-help
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34686
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bob,
The JDBC tutorial is a good place to start. You'll find that JDBC has more steps involved than PHP. The SQL translates well into SQL for a PreparedStatement:
"SELECT * FROM riverview WHERE month = ? AND year= ?"

On a high level you:
Get a Connection
Execute a PreparedStatement
Get a ResultSet
Loop through the ResultSet
Close the Connection/PreparedStatement/ResultSet

After you take a look at the tutorial, post questions you have in this thread.
 
Bob Thompson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll have to take a look at that but wont be able to right now. Last day of classes are tomarrow then finals week so i may be pretty busy, its not for a class so there's really no hurry. I'm sure i'll have questions later though, thx for the link
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34686
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bob,
Good luck on your finals. We'll still be here afterwards when things are more relaxed
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic