| Author |
Dont know much sql in java...
|
Bob Thompson
Greenhorn
Joined: Jul 30, 2005
Posts: 22
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26192
|
|
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.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Bob Thompson
Greenhorn
Joined: Jul 30, 2005
Posts: 22
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26192
|
|
Bob, Good luck on your finals. We'll still be here afterwards when things are more relaxed
|
 |
 |
|
|
subject: Dont know much sql in java...
|
|
|