aspose file tools*
The moose likes JDBC and the fly likes SQL Search Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL Search" Watch "SQL Search" New topic
Author

SQL Search

Chase Becicka
Greenhorn

Joined: Feb 16, 2004
Posts: 23
*I am working on a program and already have everything working and I can query the database as well as add and delete enteries and navigate, but the search portion is not working I want to be able to search by item # from the database, is there anything you can see I am missing or should attempt?
If more clarification is needed please ask
//1st File
public static Game searchRecord(String search) throws SQLException{
String query = "SELECT* " + "FROM gamefields WHERE SKU = '" + search + "' ORDER BY SKU ASC";
Game lastGame = new Game(gamefields.getString(1),
gamefields.getString(2),
gamefields.getString(3),
gamefields.getString(4),
gamefields.getString(5),
gamefields.getString(6),
gamefields.getString(7),
gamefields.getDouble(8));


Statement statement = connection.createStatement(); //Creates connection
//statment to database
statement.executeUpdate(query); //Executes the delete query and Updates the database
statement.close();
close();
open();
return lastGame;


//2nd File
public void keyPressed(KeyEvent e){
int keyCode = e.getKeyCode();
if (keyCode == KeyEvent.VK_ESCAPE){
performGameDisplay();
enableButtons(true);
SKUField.requestFocus();
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
This is just a guess since you didn't post the type of error your are getting. This code doesn't look right:

Correct me if I'm wrong but it looks like you are trying to use the results of the search query to initialize a Game object. If so, then you should be doing something more like this:

[ March 16, 2004: Message edited by: Blake Minghelli ]

Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
Chase Becicka
Greenhorn

Joined: Feb 16, 2004
Posts: 23
I'm sorry I forgot to include the error's, They alternate between no row count can be produced and no data found and that happens wheather or not the SKU # is inside the database, It all occurs during execution as well not when I compile.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL Search