File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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 and Relational Databases
Bookmark "SQL Search" Watch "SQL Search" New topic

SQL Search

Chase Becicka

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),

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

//2nd File
public void keyPressed(KeyEvent e){
int keyCode = e.getKeyCode();
if (keyCode == KeyEvent.VK_ESCAPE){
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

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:
subject: SQL Search
It's not a secret anymore!