Setting the CLASSPATH for the derby.jdbc embedded class

I am new to Java and am trying to connect a simple (hello world simple) terminal app to a javadb embedded database - I am using the classFor to load the jdbc - but when I run my app I get an error saying the class can't be found. I think I just need to add the jdbc to my classpath. I've tried using
export CLASSPATH=...
but I still get the same error.

Thank you SO much for your response! I have tried the following (this is where I found the derby.jar):
javac -cp /usr/lib/jvm/java-6-sun-1.6.0.07/db/lib/derby.jar test.java
But I am still getting the same error:
java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver
Here is my code - so far it doesn't really do anything, I just want to get it connected, then I'll start adding some simple db code and go from there:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
class HelloDave
    public static void main(String[] args)
        try
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
        catch (Exception e)
            e.printStackTrace();
        System.out.println("Hello, Dave");
}

Similar Messages

  • How to set the size of a class that extends JDialog

    Hi,
    I was trying to set the size of my dialog window to be 600 by 600, but couldn't change it. Here is my code:
    public class alii extends JDialog {
    /** Creates new form alii */
    public alii(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();
    private void initComponents() {
    Container contentPane = getContentPane();
    addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowClosing(java.awt.event.WindowEvent evt) {
    closeDialog(evt);
    pack();
    public static void main(String args[]) {
    JFrame frame = new JFrame();
    alii a = new alii(new javax.swing.JFrame(), true);
    frame.setSize(600,500);
    frame.setLocation(200,200);
    frame.setVisible(true);}}
    Please help me with this and explain to me what is the problem and what needs to be changed.
    Cheers

    Hi,
    The code you sent me doesn't work, and the code I posted wasn't a complete, but there is the complete one. You can see now what the code does.
    * alii.java
    * Created on 15 November 2003, 13:31
    * @author Ali
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.util.*;
    import java.io.*;
    import java.applet.*;
    import java.net.*;
    public class sun extends JDialog {
    int x[] = new int[4];
    int y[] = new int[4];
    int w[] = new int[4];
    int h[] = new int[4];
    int Y_ax = 310;
    double DrawGraf[][] = new double[4][4];
    String line[] = new String[9];
    double Perc[] = new double[4];
    double Sum=0;
    GUICanvas can;
    double graphvalue[] = new double [5];
    /** Creates new form alii */
    public sun(Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();
    //setVisible(true);
    //setSize(600,500);
    //setLocation(200,200);
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    private void initComponents() {
    //Container contentPane = getContentPane();
    addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowClosing(java.awt.event.WindowEvent evt) {
    closeDialog(evt);
    //contentPane.setSize(700,700);
    //pack();
    public void drawthegraph(String s)
    /* try {
    URL url = new URL(
    "http://localhost:111/test/servlet/Compare?value="+s);
    BufferedReader in = new BufferedReader(
    new InputStreamReader(url.openStream()));
    for (int c = 0; c<9; c++)
    line[c] = in.readLine();
    in.close();
    }catch (Exception e){
    e.printStackTrace();
    graphvalue[0] = 200;
    graphvalue[1] = 200;
    graphvalue[2] = 100;
    graphvalue[3] = 300;
    graphvalue[4] = 20;
    //graphvalue[4] = can.d2i(graphvalue[4]);
    //System.out.println(line[8]);
    Sum = graphvalue[0]+graphvalue[1]+graphvalue[2]+graphvalue[3];
    Perc[0] = graphvalue[0]/Sum*200;
    Perc[1] = graphvalue[1]/Sum*200;
    Perc[2] = graphvalue[2]/Sum*200;
    Perc[3] = graphvalue[3]/Sum*200;
    System.out.println(Perc[0]);
    DrawGraf[0][0] = 130;
    DrawGraf[0][1] = Y_ax - Perc[0];
    DrawGraf[0][2] = 60;
    DrawGraf[0][3] = Perc[0];
    DrawGraf[1][0] = DrawGraf[0][0]+60;
    DrawGraf[1][1] = Y_ax - Perc[1];
    DrawGraf[1][2] = 60;
    DrawGraf[1][3] = Perc[1];
    DrawGraf[2][0] = DrawGraf[1][0]+60;
    DrawGraf[2][1] = Y_ax - Perc[2];
    DrawGraf[2][2] = 60;
    DrawGraf[2][3] = Perc[2];
    DrawGraf[3][0] = DrawGraf[2][0]+60;
    DrawGraf[3][1] = 310 - Perc[3];
    DrawGraf[3][2] = 60;
    DrawGraf[3][3] = Perc[3];
    for(int d=0;d<4;d++)
    x[d]=d2i(DrawGraf[d][0]);
    y[d]=d2i(DrawGraf[d][1]);
    w[d]=d2i(DrawGraf[d][2]);
    h[d]=d2i(DrawGraf[d][3]);
    repaint();
    static int d2i(double d) {return (int) Math.round(d);}
    public void paint (Graphics g)
    g.setColor(Color.red);
    for(int d=0;d<4;d++)
    g.fill3DRect(x[d],y[d],w[d],h[d],true);
    g.setColor(Color.blue);
    g.drawLine(130,130,130,310);
    g.drawLine(130,310,370,310);
    g.setColor(Color.black);
    g.drawString("WELCOME TO Ali",150,100);
    g.drawString("Region: Lambeth",430,150);
    g.drawString("Manger: ",430,170);
    g.drawString("Location: ",430,190);
    g.drawString("Number of Staff: "+graphvalue[4],430,210);
    g.drawString("Week1",135,345);
    g.drawString("Week2",195,345);
    g.drawString("Week3",255,345);
    g.drawString("Week4",315,345);
    g.drawString(" "+"20 -",100,295);
    g.drawString(" "+"40 -",100,255);
    g.drawString(" "+"60 -",100,215);
    g.drawString(" "+"80 -",100,175);
    g.drawString("100 -",100,135);
    g.setColor(Color.yellow);
    g.drawLine(130,290,370,290);
    g.drawLine(130,250,370,250);
    g.drawLine(130,210,370,210);
    g.drawLine(130,170,370,170);
    g.drawLine(130,130,370,130);
    /** Closes the dialog */
    private void closeDialog(java.awt.event.WindowEvent evt) {
    setVisible(false);
    dispose();
    * @param args the command line arguments
    public static void main(String args[]) {
    JFrame frame = new JFrame();
    sun sn = new sun(frame, true);
    frame.setSize(600,500);
    frame.getContentPane().add(sn);
    frame.setLocation(200,200);
    frame.setVisible(true);
    You were right that I am know to this, but getting there slowly and thanks for your help.
    Cheers

  • How to set a classpath for referring classes

    I am using windows vista.....I had assigned classpath for Variable name and given address of class in variable type ..even then compiler does not recognize class path..........

    Thanks but it is not what I am really asking or I may didnt understand..
    The program is working ok through JCreator.. My problem is when I create an Installation file and then run it..
    the program is being created just fine but when it has to load the jdic then it blocks...
    This is something that must be done through variables right?
    If you ever used Install4J there are 2 columns where you declare variables..
    The first column is for Variable name and the second one is Variable Value..
    Sorry for buthering you with all this but this is the first time that I am dealing with jar files!
    Thanks again !

  • Setting up classpaths for the TextLayout Component in FlashDevelop for Flash CS4

    I'm trying to work with the new TextLayout Component in FlashDevelop.
    Maybe I'm lazy but I've gotten used to code completion. I want to import things like TextFlow and ICharacterFormat. How can I import these classes and others from the flashx.textLayout package so that code completion will work in FlashDevelop?

    For FlashDevelop do the following;
    Download the TextLayoutFramework swcs, there are 3 of them;
    http://download.macromedia.com/pub/labs/textlayout/textlayout_framework_p1_111808.zip
    Create new project in flash develop, put these swcs in the lib folder and in the flash develop panel on the right, ctrl click on them to select them all and right click, add to library.
    Neil

  • How to set classpath for third party jdbc-driver

    my application contains bc4j jsp. when i try to run this jsp application which connect to postgresql, i get a error message
    "Application Error
    Return
    Error Message: JBO-30003: The application pool (App_ModLocal) failed to checkout an application module due to the following
    exception:
    Error Message: JBO-26061: Error while opening JDBC connection."
    how to solve this.

    The JDBC for your database should be added to your client project.
    In JDeveloper created a new 'named' library item and specify the JDBC jar files for your database.
    See also related article
    http://otn.oracle.com/products/jdev/howtos/bc4j/bc_pdb2walkthrough.html#edit
    - Sathish

  • Could anyone help me with setting up classpath for an application in OC4J

    I am using OAS 10.1.2 OC4J embedded.
    I have lotsof.properties files in some directory external to OAS.
    Right now, since we had problems, I moved the properties files into the OC4JHOME/applib directory. It works.
    I would like to keep it in the external directory itself. Can we set up some environment variable (CLASSPATH or library) in some deployment or orion descriptors to point to this external directory.
    I am using ResourceBundle.getResource("yyy.properties") in the code.
    Thank you

    One possible solution (I think):
    In the file OC4J_HOME/config/application.xml, we added the following line.
    <library path="directory"/>
    This directory is not EAR or WAR context relative. It can anywhere be in the local system.
    Thanks

  • Problem in setting the parameters for an OASingleSelectionBean

    Hi,
    I have created an advanced table, for which I have to allow single selection or mutliple selection according to my requirements ie dynamically. So, for single selection, I have created a OASingleSelectionBean dynamically and add this to my advanced table bean.
    I also want to set Action for the single selection option. I have set the action using
    setPrimaryClientAction() which takes an argument of oracle.cabo.ui.action.FirePartialAction class. Now I also want to pass certain parameters when the single selection event happens.
    For that, I have taken an object of FirePartialAction class and but using the FirePartialAction class .setParameters(oracle.cabo.ui.collection.Parameter[]) function. I am setting the parameters using
    Parameter class object.setKey
    Parameter class object.setValue
    But my problem is that I want the value for the parameters at runtime, for which I intend to use SPEL. But I am not able to use SPEL using the setValue method.
    So it goes like this in short:
    OAAdvancedTableBean.setTableSelection(OASingleSelectionBean)
    OASingleSelectionBean.setPrimaryClientAction(FirePartialAction)
    FirePartialAction.setParameters(Parameter[])
    Parameters.setKey(String)
    Parameters.setValue(String) --- In case of value I want to give SPEL as an argument as I get the value at rutime
    Is that any other way in which I can set the value for the parameters using SPEL?

    Hi,
    I got ur point.
    Although i have never tried.........Can you try using method
    Parameters.setValueBinding(new OADataBoundValueViewObject(<single selectionbean>,<vo attr>))
    In this way without the use of SPEL, you will be able to achieve the functionality!
    Try this and get back to me!
    --Mukul
    Message was edited by:
    Mukul Gupta

  • JDBC driver - Class oracle.jdbc.driver.OracleDriver not found.

    Greetings:
    When I tried to compile an test script (as attached below) to test the driver, I always ended up with the following error message:
    ....java:17: Class oracle.jdbc.driver.OracleDriver not found.
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Could somebody shine some light on it? I would very much appreciate it.
    By the way, I have an Oracle DBMS (8.1.7) with jre1.1.7. My Java is jdk1.2 and the driver is ocijdbc8.dll
    Wil
    *************** The test script *************
    import java.sql.*;
    class Users
    public static void main (String args [])
    throws SQLException, ClassNotFoundException
    // Load the Oracle JDBC driver
    Class.forName ("oracle.jdbc.driver.OracleDriver");
    // Connect to the database
    // You can put a database name after the @ sign in the connection URL.
    Connection conn =
    DriverManager.getConnection ("jdbc:oracle:oci8:@US10", "QM24202E", "QM24202E");
    // Create a Statement
    Statement stmt = conn.createStatement ();
    // Select ... table
    ResultSet rset = stmt.executeQuery ("select USERID from USERS");
    // Iterate through the result and print the ... names
    while (rset.next ())
    System.out.println (rset.getString (1));

    check out what thomas Fly wrote on another discussion forum about connection with JDBC, i tried it and i haven't gotten it
    to work yet but at least i don't have the "... not found" error,
    you should try it too, and i think it's good to tell you that i
    still haven't installed the oracle client on my windows Me PC.
    Hope this help you
    This may help also... I have Oracle installed on a Linux PC at 192.168.1.4 on my LAN, listening on port 1521. I can connect from another PC (Linux / Windows ME dual boot, though running Windows at the time of this experiment) using the following program:
    import java.sql.*;
    public class sqlLookup {
    public static void main(String[] args) throws SQLException, ClassNotFoundException {
    String dbUrl = "jdbc:oracle:thin:@192.168.1.4:1521:ORA8";
    String user = "thomasfly";
    String password = "maverick";
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection c = DriverManager.getConnection(dbUrl, user, password);
    Statement s = c.createStatement();
    // SQL code:
    ResultSet r = s.executeQuery("select * from members");
    while(r.next()) {
    // Capitalization doesn't matter:
    System.out.println(r.getString("Name") + ", " + r.getString("id") + ": " + r.getString("email") );
    s.close(); // Also closes ResultSet
    I downloaded classes12.zip for Oracle 8.1.7 and put it into the C:\Windows directory, and mounted C:\Windows\classes12.zip in Forte for Java (equivalent to adding it to the classpath if I were running the program from a DOS window, rather than in Forte).
    ORA8... capitalization may be important... is the name of my database, which may be found in the tnsnames.ora file in $ORACLE_HOME/resources.
    The query gets the Name, id, and email fields from the table "members" in the database.
    This is just a barebones program, and each time it's run, the Oracle listener has to be stopped and restarted before the program can be successfully run again.

  • Setting the classpath of the JVM for OC4J

    Is there any way to add a path to the classpath when the embedded OC4J is run? Although the OC4J is finding my classes, the Oracle JDBC driver isn't. Here's a bit more info:
    I've been having a bit of a problem getting database java objects ("CREATE TYPE...EXTERNAL NAME...LANGUAGE JAVA USING SQLData") instantiated on the client.
    - I have an object table of type t_my_type with Java class "mypackage.MyType".
    Code sample:
    ResultSet rs = myStatement.executeQuery(
    "SELECT VALUE(p) FROM my_type_table p" );
    rs.next();
    rs.getObject( 1 );
    Exception in thread "main" java.sql.SQLException:
    Inconsistent java and sql object types:
    ClassNotFoundException: mypackage.MyType
    at
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:189)
    at
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:231)
    at
    oracle.sql.JAVA_STRUCT.toJdbc(JAVA_STRUCT.java:108)
    ... ad nauseum
    And yet when I add "-classpath /path/to/mypackage" it works fine. HOWEVER, I don't know how to add it to the OC4J startup classpath (marked "HERE" below? -- not application.xml, the one that you see in the "Log" window in jDeveloper):
    java \
    -server \
    -Xdebug \
    -classpath /path/to/oc4j/oc4j.jar:<HERE> \
    Incidentally, I'm also interested in having the Database send me the bytecode for the class ITSELF instead of having to also have a copy of the .class/.jar on the client side as well.
    Any help would be appreciated. Thanks.

    The simplest way to do this is to copy classes12.zip to the WEB-INF/lib directory. The JSP should then find this automatically.
    As a side note, that is an ancient JDBC driver - you might want to upgrade to something from this millennium.

  • Setting the classpath of classes12.zip for Tomcat

    Hi
    I am using Apache Tomcat webserver and while trying to run a jsp page which intializes oracle.jdbc.driver.OracleDriver it throws an error
    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    Please suggest how to set the classpath of classes12.zip in Apache Tomcat
    My Code Snippett
    <%@ page import="java.util.*,java.sql.*,javax.servlet.*"%>
    <body>
         <%
         Connection con ;
         ResultSet rs ;
         Statement stmt ;
         ResultSetMetaData rsmd ;
         try{ 
         Class.forName("oracle.jdbc.driver.OracleDriver");
         catch(Exception e)
         out.println(e);//print the exception on the command prompt
    %>

    The simplest way to do this is to copy classes12.zip to the WEB-INF/lib directory. The JSP should then find this automatically.
    As a side note, that is an ancient JDBC driver - you might want to upgrade to something from this millennium.

  • Where to set the classpath for custom classes in jsp

    Hi,
    we have created our custom classes in and ported in contentDB and that classes are internally using some jar files. Previously we have set the classpath of all the jar files provided in CDB devkit in the orion-web.xml but if are opening the explorer.jsp or any other jspx of contentDB we are getting the classcastexception and page is not opening.
    Is there any problem in setting the classpath. Please if any one knows abt this, reply as soon as possible.
    thanks,
    swapna soni.

    I think it is Oracle 10g Release 2... since when I click the top OAS link in the Enterprise Manager Console, it took me to 'Enterprise Manager 10g Grid Control Release 2' this page.
    And...10g Application Server Control Release 10.1.2.0.1, I think 2.0.1 means Release 2.
    Thanks and let me know if you need something else.

  • How to set the classpath for external .jar files after importing?

    Hi techs,
    How to set the classpath in WSAD5.1.2 after importing the .jar file to the WEB-INF/lib folder.
    urgent

    I got it.
    after importing the jar file to the perspective,we need to right click on project name, go to proprties,
    goto java build path,
    there we need to include the external jar files.

  • How to  set the classpath for servlet and jsp???

    i add C:\tomcat-5.0\common\lib\servlet-api+jsp-api to the class path from DOS prompt, as show below:
    set CLASSPATH=%classpath%;C:\tomcat-5.0\common\lib\servlet-api.jar;C:\tomcat-5.0\common\lib\jsp-api.jar
    then, i compile the servlet:
    javac FirstServlet.java
    no error
    and i copy the .class file into C:\tomcat-5.0\webapps\servlets-examples\WEB-INF\classes
    i set the JAVA_HOME enviroment variable as below:
    set JAVA_HOME=C:\Program Files\Java\jdk1.5.0_08
    i start the tomcat version 5.0 and run web browser and type http://localhost:8080/servlets-examples/servlet/FirstServlet
    i get the error message:
    HTTP Status 404 - /servlets-examples/servlet/FirstServlet
    type Status report
    message /servlets-examples/servlet/FirstServlet
    description The requested resource (/servlets-examples/servlet/FirstServlet) is not available.
    Apache Tomcat/5.0.30
    Can anybody tell me how to solve the problem. Thanks a lot.

    You will have to create the servlet mapping in the Web.xml file
    <servlet>
                 <servlet-name>FirstServlet</servlet-name>
                 <servlet-class>FirstServlet</servlet-class>
        </servlet>
    <servlet-mapping>
            <servlet-name>FirstServlet</servlet-name>
            <url-pattern>/servlet/FirstServlet</url-pattern>
        </servlet-mapping>

  • JAR files for SQLJ and JDBC drivers: what is the best practice?

    starting a migration from IAS 10 to WebLogic 11g.
    Apparently the jar files for SQLJ are not on the classpath by default.
    java.lang.NoClassDefFoundError: sqlj/runtime/ref/DefaultContextwhich is the better practice: putting the SQLJ runtime jar into the lib subdirectory of the domain directory, or using a shared library reference? (usage of SQLJ is pretty prevalent in our apps, though we may be getting away from it)
    are the Oracle JDBC drivers on the classpath by default?
    if not, then the same question: put them into the lib subdirectory of the domain directory, or use a shared library reference?

    I'm looking at the setDomainEnv, especially the big note at the top:
    >
    # WARNING: This file is created by the Configuration Wizard.
    # Any changes to this script may be lost when adding extensions to this configuration.
    >
    and am getting squeamish about editing it...
    http://www.bea-weblogic.com/how-do-i-disable-wls-automatically-adding-to-classpath.html looks like the default behaviour is for WebLogic to put $DOMAIN/lib;$WL_HOME/common/lib/ext;$WL_HOME/server/lib/ext on the classpath; there is also a reference to setting weblogic.ext.dirs= when starting weblogic (which means I set the WEBLOGIC_EXTENSION_DIRS environment variable).
    http://download.oracle.com/docs/cd/E12840_01/wls/docs103/programming/libraries.html#wp1067450 also refers at the bottom to using the domain /lib subdirectory.
    so am I correct that a good practice is to just put the jars I think I will globally need into $DOMAIN/lib, rather than putting them in $WL_HOME/common/lib/ext, $WL_HOME/server/lib/ext, or fiddling with the WEBLOGIC_EXTENSION_DIRS environment variable?
    Edited by: user8652010 on Feb 10, 2011 1:08 PM

  • OpenJPA is firing separate query for embedded class in the entity

    Hello experts,
    I have an Embedded class in my entity which has some common similar columns for all the tables.
    e.g
    @Entity
    @Table(name = "MY_TABLE")
    public class MyTable implements Serializable {
         //... some specific fields here
         @Embedded     
         @EagerFetchMode(FetchMode.JOIN)
         private CommonRowDetails commonRowDetails;
         //...getters and setter below
    And the class CommonRowDetails contains some audit columns as
    @Embeddable
    public class CommonRowDetails implements Serializable {
         @Column(name = "ROW_ADD_STP", updatable = false)
         private Date rowAddStp;
         @Column(name = "ROW_ADD_USER_ID", updatable = false)
         private String rowAddUserId;
         @Column(name = "ROW_UPDATE_USER_ID")
         private String rowUpdateUserId;
         @Column(name = "ROW_UPDATE_STP")
         private Date rowUpdateStp;
         //...getters and setter below
    All above columns are part of same table "MY_TABLE"
    So when I select the entity MyTable, I can see a separate query is getting executed for selecting (ROW_ADD_STP, ROW_ADD_USER_ID, ...) which is definitely not required. I also added the annotation @EagerFetchMode(FetchMode.JOIN) on field CommonRowDetails to select those with join/in same query.
    Please help me to know, how to avoid OpenJPA firing a separate query.
    ENV details
    DATABASE
    databaseProductName: DB2/LINUXX8664
    databaseProductVersion: SQL09075
    driverName: IBM DB2 JDBC Universal Driver Architecture
    driverVersion: 3.58.81
    OS-SERVER
    WebSphere Platform 8.0.0.2 [BASE 8.0.0.2 cf021148.03]
    Host Operating System is Windows XP, version 5.1
    Java version = 1.6.0, Java Compiler = j9jit26, Java VM name = IBM J9 VM
    OPENJPA- 2.1.2

    Hello Forum,
    got a response in the SAP forum - Issue is a bug in the SAP NetWeaver
    app. server.
    Henning Malzahn

Maybe you are looking for

  • When you CAN'T buy an album at a time...?

    If there is no BUY tab for an album in iTunes, and instead a VIEW tab only-the entire album cannot be bought at once? You havce to click & bill & pay each song individually? Really??

  • Question about autodiscover in case of multiple bound namespace

    Hi Experts, I have a question about the autodiscover behaviour. Let's assume we have the below infrastructure: SiteA : MBX-Server-SiteA : Member of a DAG CAS-Server-SiteA : outlook anywhere url = siteA.domain.com SiteB : MBX-Server-SiteB : Member of

  • Can't see "albums" when reviewing photos stored on external drive

    Goal: I'd like to be able to rapidly hook up my external hard-drive, find 6 photos previously sorted into an album (as when they were originally sorted by me in my computer's iPhoto) and copy those back onto my computer for my use. Problem: When I go

  • Match code list setting

    Hello, We have a specific match code list for a new field in the screen . We use Screen painter . When we display match code it will be displayed by default a list ALV . But here How can we change to a list Basic for the values of this match code . (

  • BSOD Windows 7 after clearing cache of Firefox

    When clearing the cache of Firefox this night I got a BSOD with Windows 7 Prof, causing it to memory-dump followed by a forced reboot. After restoring the backup all worked as intended but I'm hesitant whereas I should try and clear my cache. == This