Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: calling a java a class connected to derby from a batch file

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default calling a java a class connected to derby from a batch file

    Hi all,

    I've created a java class that is connected to a database (derby). It works perfectly when run from netbeans. After that I created a batch file that calls this class and put them in a folder in the C.When tested, it is clear in the cmd that all lines are excuted until the connection to the database part:

    Connection con;
    Class.forName("org.apache.derby.jdbc.ClientDriver" );
    con = DriverManager.getConnection("jdbc:derby://localhost:1527/demntiaDB", "reem", "pass");

    I get those errors:
    classNotFoundException
    URLClassLoader.run$

    this is my main:
    public static void main(String[] args) throws ClassNotFoundException {

    SwingUtilities.invokeLater(new Runnable(){
    public void run() {
    try {

    regulation r = new regulation();

    } catch (ClassNotFoundException ex) {
    Logger.getLogger(regulation.class.getName()).log(L evel.SEVERE, null, ex);

    } catch (SQLException ex) {
    Logger.getLogger(regulation.class.getName()).log(L evel.SEVERE, null, ex);

    }
    }
    });}

    what do i have to write exactly in the batch file? This is what i have right now:
    cd\
    cd "HourlyTempReg" <---- folder in which java class and batch file are placed
    java regulation.regulation <----- java java package.java class

    Thank you very much


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,356
    Thanks
    182
    Thanked 833 Times in 776 Posts
    Blog Entries
    5

    Default Re: calling a java a class connected to derby from a batch file

    Please do not double post your question to the forums, your other post has been removed.

    Does the database driver accompany your class and batch file? This must be on the classpath for your program to connect to the database.

  3. #3
    Junior Member
    Join Date
    Oct 2010
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: calling a java a class connected to derby from a batch file

    I am using netbeans to and the database connection is done within the java class to derby.In what form must i write the classpath?
    I tried this but it didnt work:
    cd\
    cd "HourlyTempReg"
    java -classpath C:\HourlyTempReg\regulation;C:\Program Files (x86)\Sun\JavaDB\lib\derby.jar;C:\Program Files (x86)\Sun\JavaDB\lib\derbyclient.jar;C:\Program Files (x86)\Sun\JavaDB\lib\derbynet.jar;C:\Program Files (x86)\Sun\JavaDB\lib\derbyrun.jar;C:\Program Files (x86)\Sun\JavaDB\lib\derbytools.jar;C:\Program Files (x86)\Sun\JavaDB\lib\register.jar; regulation.regulation

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,356
    Thanks
    182
    Thanked 833 Times in 776 Posts
    Blog Entries
    5

    Default Re: calling a java a class connected to derby from a batch file

    Your file paths have spaces...try placing the paths in quotes

  5. The Following User Says Thank You to copeg For This Useful Post:

    Reem (October 31st, 2010)

  6. #5
    Junior Member
    Join Date
    Oct 2010
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: calling a java a class connected to derby from a batch file

    It worked! thanx a million...just added the quoutes

Similar Threads

  1. Calling method from .class file
    By alexx_88 in forum Java Theory & Questions
    Replies: 6
    Last Post: April 24th, 2012, 03:14 AM
  2. Java (Derby) Help
    By Neon612 in forum JDBC & Databases
    Replies: 3
    Last Post: August 19th, 2010, 09:40 PM
  3. Help Calling Method From Another Class
    By CheekySpoon in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 15th, 2010, 10:24 AM
  4. [SOLVED] How to call string in another class in java?
    By tazjaime in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 23rd, 2009, 10:31 AM