Go Back   Java Programming Forums > Java Standard Edition Programming Help > JDBC & Databases


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-03-2010, 03:51 PM
Junior Member
 

Join Date: Mar 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
tdc5013 is on a distinguished road
Default Pulling in data from access

Hi guys, I'm not only new to this forum but to java programming in general so if I make any glaring mistakes please bare with me.

So, I'm currently writing a program that pulls in data from a database. I'm trying to make a barebones jukebox, so the idea is that I have a JFrame for seeing the entire song library, creating a playlist and updating track information. The database seems to have implemented Ok; there were a few problems but this was fixed using import java.sql.*; on each auxillary class.

Here's the problem, in the database there is a field called "key"; the track number of each song. To look at the specifics of a certain song, or to update its information, or to add it to a playlist I need to type in the track number and hit the required button. For instance, if I were to want to check Brown Sugar by The Rolling Stones, I'd enter its track number in the text field (say '4'), click "info" and then I'd see the song name, artist, rating, play count etc. The only thing is I'm getting errors whenever I search for a song. If the program can't find the track then it simply outputs "No such track number". The output from the programming package says:

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

Can anyone hazard a guess as to what the problem might be? This is really bugging me, and it's happening across the board - in every auxillary class. No tracks can be found.

Thanks in advance.

P.s. I should also note that in the main part of the jukebox, the library, the songs are actually showing up. So I know the program is contacting the database.




Last edited by tdc5013; 10-03-2010 at 03:53 PM.
Reply With Quote Share this thread on Facebook
Sponsored Links
Java Training from DevelopIntelligence
  #2 (permalink)  
Old 13-03-2010, 07:44 PM
Junior Member
 

Join Date: Mar 2010
Posts: 14
Thanks: 0
Thanked 1 Time in 1 Post
jasonm is on a distinguished road
Default Re: Pulling in data from access

I'm trying to learn data access with Java myself, but does this error indicate a problem with your search query? It sounds like the connection is being made just fine:
Quote:
I should also note that in the main part of the jukebox, the library, the songs are actually showing up. So I know the program is contacting the database.
Can you post the code where you build your search query?
Reply With Quote
  #3 (permalink)  
Old 15-03-2010, 08:40 PM
Junior Member
 

Join Date: Mar 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
tdc5013 is on a distinguished road
Default Re: Pulling in data from access

I managed to fix the problem. It turned out I had the "key" in the database as an AutoNumber, but everytime I was looking for it in the program I was using a String.

My program now more or less works fine, except for one little thing. In the part of my program where I create a playlist I want a message saying "No such track" to appear in the main textfield (called "list) if the textbox where the user inputs the key (trackNumber) is empty, or has an unrecognised input; basically if it is 'null'.

if (trackNumber == null)
//If the number doesn't correspond to anything in the library...
{
list.setText("No such track number");
//Display "No such track number" in the "information" text field
}

Except when testing this instead of the message I get "null - null".

I found that the message did actually appear whenever I changed "trackNumber" to "name" in the If statement.

( String name = LibraryData.getName(key); - LibraryData is the part of the program interacting with the database )

However, this then stops other parts of the program working - such as the reset function, which merely clears "list". The message "No such track number" just stays there.

Any ideas?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Similar Threads
Thread Thread Starter Forum Replies Last Post
access restriction??? wtf!?! wolfgar Java Theory & Questions 6 23-11-2009 11:27 AM
Default Access (package access) confusion gauravrajbehl Java Theory & Questions 1 18-11-2009 08:11 AM
Access the Same Socket ahmmnhwa Java Networking 5 29-10-2009 03:50 PM
Random Access File silver_unicorn File I/O & Other I/O Streams 1 12-08-2009 06:51 AM
Random Access File silver_unicorn File I/O & Other I/O Streams 1 11-08-2009 03:44 AM


100 most searched terms
Search Cloud
2 dimensional arraylist java 2d arraylist java actionlistener actionlistener in java addactionlistener addactionlistener java convert double to integer java double format java double to integer in java double to integer java drag en drop programmeren java eclipse shortcut keys exception in thread "awt-eventqueue-0" java.lang.outofmemoryerror: java heap space exception in thread "main" java.lang.nullpointerexception exception in thread "main" java.lang.outofmemoryerror: java heap space format double in java format double java get mouse position java java 2d arraylist java actionlistener java double format java double formatting java double to int java double to integer java format double java forum java forums java get mouse position java list to map java mouse position java programming forum java programming forums java programming practice problems java send keystrokes to another application java two dimensional arraylist java.io.ioexception: premature eof java.lang.classformaterror: truncated class file java.lang.outofmemoryerror: java heap space java.util.arraylist jbutton action jbutton actionlistener jtextarea font jtextfield font size jxl.read.biff.biffexception: unable to recognize ole stream programming mutators and generics smack api two dimensional arraylist two dimensional arraylist java unable to sendviapost to url what is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

All times are GMT. The time now is 02:06 AM.
Powered by vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.