DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Java/JDBC Help

  1. #1
    Join Date
    Dec 2003

    Java/JDBC Help


    As a JAVA beginner, I just download J2SDK1.4.2 and NetBeans IDE 3.6. for Windows.

    I have some questions on JDBC driver and SQL function:

    1) How to find a Driver Name for Access 2000 or MS SQL except JDBC-ODBC Bridge (I have Access 2000 and SQL on my PC) for Class.forName(). --(.Jar files only?)

    2) Can I directly code Driver and its attributes for Data Source in URL instead of DSN? And how to code them?

    3) How to drop a table from a database, for example to drop a table in a MS SQL file. I can't find sample code for table drop neither in NetBeans nor JAVA (only found updating and querying).

    Appreciate your help!

  2. #2
    Join Date
    Jun 2004
    For Access - You will need to use the Bridge.

    For SQL server - go here http://jtds.sourceforge.net/ - They have a driver and directions.

    You might want to pickup Squirrel too. - squirrel-sql.sourceforge.net

    2. http://www.devdaily.com/java/edu/pj/pj010024/

    3. Do exactly like you would for an update query but use "Drop Table tablex" replacing tablex with your table name. As long as your user as the authority it will work. Check SQL Server Books Online in case the syntax is not correct. I think it is.

  3. #3
    Join Date
    Dec 2003
    Thanks for helping me on #1 and #3.

    A question on #2 for Interbase (following sample code):

    // Establish a connection to an Interbase database using JDBC.
    import java.sql.*;

    class JdbcTest1 {

    public static void main (String[] args) {
    try {

    // Step 1: Load the JDBC driver.

    // Step 2: Establish the connection to the database.
    String url = "jdbcdbc:contact_mgr";
    Connection conn = DriverManager.getConnection(url,"user1","password");

    } catch (Exception e) {
    System.err.println("Got an exception! ");

    In String url = "jdbcdbc:contact_mgr" -- Here "contact_mgr" is a database name.
    Why it did not put a full path to a database (If there are multi files with same name, such as Access in different subdirs, how URL to distinguished them)? Do I need to do some things before? Such as building a connection with Runtime ->Databases -> Driver -> Connection?

    I want to pass RUL parameters on a fly accurately.

  4. #4
    Join Date
    Jun 2004
    You will need to have different DSN's for each "database".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.