Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6576381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:30:19+00:00 2026-05-25T15:30:19+00:00

I’m having trouble running from ant. When I run straight from the class file

  • 0
    I'm having trouble running from ant.  When I run straight from the class 
    file as follows it compiles and runs

    Jasons-MacBook-Pro:src js$ java Hw5
    Student ID:  1
    First Name:  Jason
    Last Name:  S
    Phone:  555-220-5169
    Email:  js@ucsd.edu
    Personal Tagline:  Never say never

    The following line of code is used when it runs correctly as above
    Connection connection = DriverManager.getConnection("jdbc:derby:/Users/js/Desktop/JavaDevelopmentAnt/HW5_JDBC/lib/Hw5Db");

    my code

    import java.sql.*;
    import java.util.Enumeration;

    public class Hw5{
       public static void main (String [] args){
          try{
             Connection connection = DriverManager.getConnection("jdbc:derby:/Users/js/Desktop/JavaDevelopmentAnt/HW5_JDBC/lib/Hw5Db");
             //Connection connection = DriverManager.getConnection("jdbc:derby:Hw5Db");//ant file code
             Statement statement = connection.createStatement();
             ResultSet resultSet = statement.executeQuery("SELECT * FROM STUDENT");

             while(resultSet.next()){
                int studentID = resultSet.getInt("STUDENT_ID");
                String firstName = resultSet.getString("FIRSTNAME");
                String lastName = resultSet.getString("LASTNAME");
                String phone = resultSet.getString("PHONE");
                String email = resultSet.getString("EMAIL");
                String mantra = resultSet.getString("PERSONAL_TAGLINE");
                System.out.println("Student ID:  " + studentID + "\n" + 
                                "First Name:  " + firstName + "\n" + 
                                "Last Name:  " + lastName + "\n" +
                                "Phone:  " + phone + "\n" +
                                "Email:  " + email + "\n" +
                                "Personal Tagline:  " + mantra + "\n");
             }
             resultSet.close();
             statement.close();
             connection.close();         
          }
          catch(SQLException sqle){
             System.err.println("SQL Exception: " + sqle);
          }
       }
    }



    but when I try from my build.xml  i change the following line of code to
    Connection connection = DriverManager.getConnection("jdbc:derby:Hw5Db");

    because i think database jar file (Hw5Db) is in the classpath of my build.xml

    my build.xml


<?xml version="1.0"?>
   <project name="Hw5" default="compile" basedir=".">
   <property environment="env"/>
   <property name="src" value="${basedir}/src"/>
   <property name="bin" value="${basedir}/bin"/>
   <property name="lib" value="${basedir}/lib"/>
   <property name="doc" value="${basedir}/doc"/>
   <property name="build" value="${basedir}/build"/>

   <target name="prepare" description="Setting up temporary directory to support build">
      <mkdir dir="${build}"/>
      <mkdir dir="${bin}"/>
   </target>

   <target name="compile" depends="prepare" description="compile java sources">
      <javac srcdir="${src}" destdir="${build}" includes="**/*.java" listfiles="yes" includeantruntime="false">
      </javac>
   </target>

   <target name="deploy" depends="compile">
      <jar destfile="${bin}/Hw5.jar" basedir="${build}"/>
      <jar destfile="${bin}/Hw5Db.jar" basedir="${lib}"/>
    </target>

    <target name="run" depends="deploy" description="run the project">
       <java fork="true" classname="Hw5">
          <classpath path="${bin}/Hw5.jar"/>
          <classpath path="${bin}/Hw5Db.jar"/>
       </java>
    </target>

    <target name="clean">
       <delete dir="${build}"/>
       <delete dir="${bin}"/>
    </target>
</project>

Jasons-MacBook-Pro:HW5_JDBC jsteindorf$ ant run
    Buildfile: /Users/js/Desktop/JavaDevelopmentAnt/HW5_JDBC/build.xml

    prepare:
        [mkdir] Created dir: /Users/js/Desktop/JavaDevelopmentAnt/HW5_JDBC/build
        [mkdir] Created dir: /Users/js/Desktop/JavaDevelopmentAnt/HW5_JDBC/bin

    compile:
        [javac] Compiling 1 source file to /Users/js/Desktop/JavaDevelopmentAnt/HW5_JDBC/build
        [javac] /Users/js/Desktop/JavaDevelopmentAnt/HW5_JDBC/src/Hw5.java

    deploy:
          [jar] Building jar: /Users/jsteindorf/Desktop/JavaDevelopmentAnt/HW5_JDBC/bin/Hw5.jar
          [jar] Building jar: /Users/jsteindorf/Desktop/JavaDevelopmentAnt/HW5_JDBC/bin/Hw5Db.jar

    run:
         [java] SQL Exception: java.sql.SQLException: No suitable driver found for jdbc:derby:Hw5Db

    BUILD SUCCESSFUL
    Total time: 2 seconds    

    I'm trying, I just can't get it to work
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:30:20+00:00Added an answer on May 25, 2026 at 3:30 pm

    i fixed the issue, the build.xml wasn’t finding to the database drivers

    classpath path=”${env.DERBY_HOME}/lib/derby.jar

    classpath path=”${env.DERBY_HOME}/lib/derbytools.jar

    and the connection path to the database should have been

    jdbc:derby:./lib/Hw5Db

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am currently running into a problem where an element is coming back from
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a bunch of posts stored in text files formatted in yaml/textile (from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.