Sun's JDBC Tutorial. Run Into a Problem

im working through suns JDBC tutorial but ive run into a problem. when i try to run the application i get a whole lot of exceptions. heres my class for working through with the tutorial:
package JavaPhonebook;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JDBCTutorial{
    public static void main(String[] args){
        Connection con;
        Statement stmt;
        ResultSet srs;
        try{
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
            con = DriverManager.getConnection("jdbc.derby.COFFEES");
            stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
            srs = stmt.executeQuery("SELECT COF_NAME, PRICE FROM COFFEES");
            while(srs.next()){
                String name = srs.getString("COF_NAME");
                float price = srs.getFloat("PRICE");
                System.out.println(name + " " + price);
        }catch(ClassNotFoundException ex){
            ex.printStackTrace();
        }catch(SQLException ex){
            ex.printStackTrace();
}when i run it i get these exceptions:
java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at JavaPhonebook.JDBCTutorial.main(JDBCTutorial.java:30)Message was edited by:
Alex1989

Do you know what a classpath is?nope
Well this (classpath) is the crux of your problem.
How are you running this program? In netbeans.
well i registered java db by going to tools ->
options -> advanced options -> ide configuration ->
server and external tool settings -> java db database
and then choosing the java db location and database
location... this seems to be something netbeansy.
But this did not answer my question really.
All I can tell you is that you need to have all the directories and/or jarfiles your program needs to run in your runtime classpath. Runtime as opposed to compile time. I suspect that this "registration" process of which you speak is related to your compile-time classpath but either not your runtime classpath or you are not running in Netbeans.

Similar Messages

  • Sun's JDBC Tutorial. Need a Little Help

    im learning about JBDC using suns tutorial but ive run into a problem. on this page here http://java.sun.com/docs/books/tutorial/jdbc/basics/retrieving.html about 1/7th of the way through they give u some code. but when i used it in my IDE (netbeans 5.5) i get 2 errors:
            try{
                Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
                Connection con = DriverManager.getConnection("jdbc.derby.COFFEES");
                Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
                ResultSet srs = stmt.executeQuery("SELECT COF_NAME, PRICE FROM COFFEES");
            }catch(ClassNotFoundException ex){
                ex.printStackTrace();
            }catch(SQLException ex){
                ex.printStackTrace();
    D:\Java\Java Phonebook\src\JavaPhonebook\JDBCTutorial.java:32: incompatible types
    found   : java.sql.Statement
    required: java.beans.Statement
                stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
    D:\Java\Java Phonebook\src\JavaPhonebook\JDBCTutorial.java:33: cannot find symbol
    symbol  : method executeQuery(java.lang.String)
    location: class java.beans.Statement
                srs = stmt.executeQuery("SELECT COF_NAME, PRICE FROM COFFEES");
    2 errorsMessage was edited by:
    Alex1989

    You should learn how to read and make sense of compiler error messages. This one is not hard to understand.
    "found : java.sql.Statement
    required: java.beans.Statement"
    What does that suggest to you? Does it suggest that the compiler is getting confused between java.sql.Statement and java.beans.Statement? It should.
    So how do you fix this? Two options
    1) You can stop importing java.beans.Statement. I think you should explore this route first because it seems to me that you are importing packages and classes for which you have no need.
    2) You can indicate specifically which Statement you want in your code.

  • When I plug my iPhone 4s into my PC, I get an error message that says iTunes needs a newer version of Apple Mobile Device Support. It wants me to uninstall both the AMDS and iTunes and then reinstall iTunes. Has anyone else run into this problem recently?

    When I plug my iPhone 4s into my PC, I get a message that says iTunes needs a newer version of Apple Mobile Device Support. It wants me to uninstall both the AMDS and iTunes and then reinstall iTunes. iTunes won't recognize my phone and so I can't synch it. Has anyone else run into this problem recently and how did you resolve it? Thanks!

    Thank you both. I suppose I should have prefaced my question with the concern that I've read a number of other posts from people who have had a similar issue and when they tried to follow the directions, they ran into a multitude of other problems. As you might imagine, I'm hoping to avoid the creation of new problems as I try to solve this one. Thanks again.

  • I have a Macbook pro 2009 with Snow Leopard.  Which system can I install without running into complicated problems which I will not be able to solveby myself? (Mountain Lion, Mavericks, Yosemite?)

    I have a Macbook pro 2009 with Snow Leopard.  Which system can I install without running into complicated problems which I will not be able to solve by myself- a person with limited problem solving abilities. (Mountain Lion, Mavericks, Yosemite?)

    It will make it easier to help you w/ your problem to know the  size and RAM installed.
    "Yesterday I couldn't update the maps on my Garmin because it said the OS I had wouldn't work"
    What OS will your Garmin work with? Funny there was someone else that did that and upgraded to Yosemite and regretted it.
    I'd say Lion if your Garmin is compatible.
    Both Lion and Mountain Lion are downloadable from the Apple Store:
    http://store.apple.com/us/product/D6106Z/A/os-x-lion
    http://store.apple.com/us/product/D6377Z/A/os-x-mountain-lion
    The OSs will get more resource hungry the higher you go.

  • Has anyone run into the problem of downloading or opening an E.pdf file? I am running on 10.6.8 and am unable to open the file. Any suggestions?

    Has anyone run into the problem of downloading or opening an E.pdf file? I am running on 10.6.8 and am unable to open the file. Any suggestions?

    That crash appears to be casued by the Facebook plug-in.
    Create a new account (systempreferences -> accounts or Users & Groups on 10.7 and 10.8), make a new Library in that account, import some shots  and see if the problem is repeated there. If it is, then a re-install of the app might be indicated. If it's not, then it's likely the app is okay and the problem is something in the main account.

  • I am trying to use the brightness adjustment on a grayscale photoshop CS6 file.  The preview shows the adjustment working and changes the brightness, but when you click to apply the change, it does not apply the adjustment.  I have run into this problem b

    I am trying to use the brightness adjustment on a grayscale photoshop CS6 file.  The preview shows the adjustment working and changes the brightness, but when you click to apply the change, it does not apply the adjustment.  I have run into this problem before, although rarely, with some other files over the years and with earlier versions of CS.  I would like to know how to overcome this problem?

    Make sure you are viewing your image at 100%. At smaller views, pixels and layers and the way they interact are approximate interpolations and won't show you the actual pixel-for-pixel changes.

  • I've run into a problem with my trail version of Adobe Premier 13, and it appears to be a major one.

    I’ve run into a problem with my trail version of Adobe Premier 13, and it appears to be a major one. Here’s what happened.  Yesterday when I turned on the computer, I got a prompt asking if I wanted to link my Adobe Lightroom with Adobe Premier.  I “x’d” the prompt but then the computer went into a “do not turn off” mode.  45 minutes later the computer was still prompting me not to turn it off. Thinking that the computer was hung up I did turn it off.  Then I turned it back on, went to Adobe Lightroom to discover that all my work from the past three-to four years had disappeared. 
    At this point I am afraid to mess with Adobe Premier, so it’s still on my computer.  I used Windows 7, Photoshop CS3 and Lightroom 4.  Do you think if I uninstalled my trial version of Adobe Premier 13, my work on Lightroom would return?  Or is it lost?
    Thanks to any who offer suggestions. 
    Bert Gildart

    Bert Gildart
    I was unaware that you could establish any direct linkage between Lightroom and Premiere Elements. Are you sure that the association was to be for  Photoshop CS3 and Lightroom?
    Have you tried to do a System Restore to a point before you installed Premiere Elements 13 or before you OK'd whatever this Lightroom linkage was?
    Have you asked your question in the Adobe Lightroom Forum, asking about recovery of work lost from Lightroom? Have you found any traces of your lost Lightroom work in the Recycle Bin?
    ATR

  • Encoder keeps running into a problem and closes adobe premiere pro down too.

    Hello, i have be trying to open my Encoder but for some reason it keeps running into a problem and closing on me and has a time or two closed down my adobe premiere pro down too. What is happening?

    Hi. I have the same problem using an HTC Incredible Android smartphone. The video/audio not in sync. Slight advance or delay. Not matching. I have the phone set to record as mp4, but when I use the file it says 3gp, so I transcode it to mp4. I have filmed a lot with my smartphone and now I have all this footage for over 6 months that may have this problem so I seriously need to know how to fix this or I have a ton of bad footage showing me in frame talking and it's not going to be right for YouTube videos of selfie-vlogging. So, I need to know the best, most fool-proof, most efficient, time-saving way to process and make it workable without taking too much time. Please share the very best methods which work 100% of the time. Thanks, JR
    Message was edited by: XXJR2013XX

  • When installing Oracle9i I run into a problem on the 3rd CD

    I am installing Oracle9i and on the third CD I am running into a problem. When the Configuration Tools are downloading, I am not able to download the "Oracle Database Configuration Assistant." It says that the SID I have created (during installation of the first CD) is already in use. How do I go about changing the SID I picked???? Does anyone know???

    Bert Gildart
    I was unaware that you could establish any direct linkage between Lightroom and Premiere Elements. Are you sure that the association was to be for  Photoshop CS3 and Lightroom?
    Have you tried to do a System Restore to a point before you installed Premiere Elements 13 or before you OK'd whatever this Lightroom linkage was?
    Have you asked your question in the Adobe Lightroom Forum, asking about recovery of work lost from Lightroom? Have you found any traces of your lost Lightroom work in the Recycle Bin?
    ATR

  • Basic Objects - run into a problem already!

    Hi guys, got a problem with my objects already :(
    Just started working with them, here is my code
    Object class:
    public class Pupil {
         public static int scoreMaths;
         public static int scoreGeog;
         public Pupil(int m, int g){
              scoreMaths = m;
              scoreGeog = g;
         public int getMaths(){
              return scoreMaths;
         public int getGeog(){
              return scoreGeog;
    }and here is my main class:
    public class Results{
         public static Pupil Matthew = new Pupil (93, 92);
         public static Pupil David = new Pupil (21, 20);
         public static void main (String argv[]){
              System.out.println("Matthews Math score is " + Matthew.getMaths());
              System.out.println("Matthews Geog score is " + Matthew.getGeog());
              System.out.println("Davids Math score is " + David.getMaths());
              System.out.println("Davids Geog score is " + David.getGeog());
    }Its really straightforward (or so I thought) but when I run it, all the scores are Davids (i.e. both Math scores are 21 and both Geog scores are 20). If I swap the lines round so Matthew is created second, then all the scores are Matthews.
    Why is the second object overwriting the first?
    plz help!

    Works for me:
    public class Pupil {
        private int scoreMaths;
        private int scoreGeog;
        public Pupil(int m, int g){
            scoreMaths = m;
            scoreGeog = g;
        public int getMaths(){
            return scoreMaths;
        public int getGeog(){
            return scoreGeog;
    public class Results {
        public static void main (String[] args){
            Pupil Matthew = new Pupil (93, 92);
            Pupil David = new Pupil (21, 20);
            System.out.println("Matthews Math score is " + Matthew.getMaths());
            System.out.println("Matthews Geog score is " + Matthew.getGeog());
            System.out.println("Davids Math score is " + David.getMaths());
            System.out.println("Davids Geog score is " + David.getGeog());
    }Suggestion: it's easy to go "static crazy" when learning Java. Try to make main your only use of static.

  • HT201269 Following these steps, has anyone run into the problem of losing the 4s data ability?  My phone no longer acknowledges my data plan.  I have to reset to factory settings to get it back, but then I also lose all the first gen backup transfer info.

    Long story short, I'm trying to progress from my first gen iPhone to my iPhone 4s.  I sync my first gen as directed to create a backup, and then restore my 4s to the first gen backup.  However, once this is done (and it does successfully transfer my first gen phone apps, photos, texts, calendar, etc-etc to my 4s), my 4s phone no longer has 4g data like it did prior to syncing - it doesn't recognize my data plan at all.  The only way I can access the internet is through my wi-fi.  So then I have to reset to factory settings and re-plus my personal settings into the 4s but then I lose everything from the first gen transfer.  Any thoughts and/or recommendations/suggestions?  Many thanks.

    Long story short, I'm trying to progress from my first gen iPhone to my iPhone 4s.  I sync my first gen as directed to create a backup, and then restore my 4s to the first gen backup.  However, once this is done (and it does successfully transfer my first gen phone apps, photos, texts, calendar, etc-etc to my 4s), my 4s phone no longer has 4g data like it did prior to syncing - it doesn't recognize my data plan at all.  The only way I can access the internet is through my wi-fi.  So then I have to reset to factory settings and re-plus my personal settings into the 4s but then I lose everything from the first gen transfer.  Any thoughts and/or recommendations/suggestions?  Many thanks.

  • HTML code appears corrupted - anyone run into this problem?

    Using RH8 HTML - All of my topics have unusual spacing in the html code.  This happens with a brand new project - starting right from the menu to select a new project.  As soon as the project is created I go into the first topic and look at the html code and it looks something like this:
    OK, even though it's hard to read, you can get the jist of it.  This happens with old or new projects.
    I am hoping I do not have to have our IT staff perform a uninstall/install.  Any feedback is greatly appreciate.
    Rob

    Just want to add that the usual trick of restoring the default font to Courier at 100% does not work as the dropdown is blank when Robert accesses it.
    Also this applies to any project Robert opens, including the samples.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • Has anyone else run into this problem?

    I am developing a combined java and flex project, and it was working fine as a web app. Usinf flash builder I converted it to a desktop air project, and now it fails to send messages to java. eg, My test code just calls a java class's hello() method when i click a button, and an alert shows "hello", which is what the java class returns. However I get an error in the air version, when I click the button it gives an error saying:
    faultCode:Client.Error.MessageSend
    faultString:'Send failed'
    faultDetail:'Channel.Connect.Failed error
    NetConnection.Call.Failed: HTTP: Failed: url:
    'http://ombination.swf/Combination/messagebroker/amf''
    I can see the problem there, my project is called Combination, as is the swf file but for some reason it is looking for "ombination.swf". Weird problem any ideas? I tried changing the name of the swf file to ombination as a quick fix, but then the air can't load it.

    As I originally said, 'with the best will in the world', and that is not a narrow minded approach.   More, had you spent a little time on the net you could have located this link ...
    http://www.lmp-adapter.com/site/index.cfm?nodeRoute=d05&step=2f322&l=1&vsprache= en&id_art=80839&plainerr=1
    And if this is not enough, if you will oblige us with details of the item you complain about, I will try to locate more info for you.
    But frankly, I think you should try a little harder to help yourself.

  • My edits in Photos 1.0 are not changing the photos. Are others running into this problem?

    I uploaded photos from my iPhone.
    When I try to edit them on my Mac, nothing happens. I can move all the adjustment bars (brightness, shadows, highlights, etc., but nothing happens to the photo.

    I had the same problem, it never happened in iPhoto.
    Simple solution: quit Photos and start again, it will work.

  • *** Running into HUUUGE problems integrating stills into my video project

    I am editing an HDV project and trying to incorporate 1920x1080 @ 150dpi still image files. I've tried them as .jpg and as .psd and the problem still persists. Here's what the images look like in the timeline:
    http://www.cloudninecreative.com/problem1.jpg (actually, this is how it's supposed to look, more or less)
    http://www.cloudninecreative.com/problem2.jpg
    http://www.cloudninecreative.com/problem3.jpg
    I can't for the life of me figure out what the problem is. It doesn't matter if I change the pic from 8 bit to 16 bit, or if I export it as a picture using Quicktime conversion right out of FCP - it never works. The weirdest thing is that it plays and looks fine in the FCP timeline - it's when I export to a self-contained Quicktime file where the problem seems to occur.
    Does anyone have any suggestions? I'm trying to get this project done and it's literally driving me crazy!!!!!!!!!!!!
    Message was edited by: Big MaCanadian
    Message was edited by: Big MaCanadian

    Hi Nick - thanks for your help!
    I don't think I explained it correctly. The problem is occurring when I select File > Export > Quicktime Movie (i.e. _full quality_ and NOT Quicktime conversion). "Current Settings" is what I'm leaving the settings window at... If I'm exporting it this route, shouldn't it be exactly what I see in the timeline?
    Using Quicktime conversion was only my way to try and solve the problem, not where the problem originated...
    Message was edited by: Big MaCanadian

Maybe you are looking for

  • New version - can no longer authenticate with BT

    I've been syncing my 6230 with my Windows XP (SP2) workstation for ages. Until I recently installed 6.80.20. Now as soon as I get a connection, it then says "Cannot authenticate the phone". Other posts made me suspect the driver, but I dont know what

  • How to create a function that returns multiple rows in table

    Dear all, I want to create a funtion that returns multiple rows from the table (ex: gl_balances). I done following: -- Create type (successfull) Create or replace type tp_gl_balance as Object PERIOD_NAME VARCHAR2(15), CURRENCY_CODE VARCHAR2(15), PERI

  • Can't find newest backup - restoring TM backup from TC to MBP with new HD

    So I bought an SSD for my MacBook Pro and am excited to get it in there, but I'm very particular about my settings, apps, data, and even my Chrome session (many tabs worth) going back to exactly as I left it when I first boot up with that new SSD. I

  • Add selected table row value to PageFlowScope so I can access in taskflow

    Hi all, Running into a problem getting a value from a selected ADF table row to a taskflow that is displayed as an inline popup. Here's the scenario. I have a view which displays a table. When I click on an edit btn I display my taskflow as an inline

  • XPath/XSLT 2.0?

    Is xMII planning to support XPath/XSLT 2.0?  Any idea when? In xMII 12.0, are custom actions provided their own classloader?  Or do they share a classloader with the core actions?  In other words, can we include Saxon 8 (XPath/XSLT 2.0) in our custom