• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SQL Search

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
*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();
 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Chase Becicka
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic