DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2004

    starting in JDBC


    I know already a bit of J2SE but I'd like to start programming with JDBC. The problem is, I don't have a PC myself, I use those at the university lab, so I have some restrictions installing stuff. I've started reading Sun's JDBC tutorial but they just say "will need a DBMS, ask your admin to install and configure it", but hey, no admin for this, so I need to know... can I do it without installing those **** InstallShield stuff which try to write in the windows registry? Do I need to configure a DB server? Can I do it like with MySQL? Where can I find that information? Yeah, I know, "google it", but in fact sometimes it's so much faster and easier if someone can help just a bit, so well I'm trying...

  2. #2
    Join Date
    Mar 2004
    you can use a MySQL database, but you still need the jdbc driver installed. (you can get it from mysql.com) If you plan on using a database from another webserver, chances are you won't be allowed to connect. Most are setup to only be accessed through the localhost, such as the scripts run from that particular server.

  3. #3
    Join Date
    Dec 2004
    I've downloaded Connector-J from MySQL's site and also installed XAMPP. The MySQL server was working (I could access it from the phpMyAdmin page), but I couldn't find the correct string for gettting a connection (though the tutorial said it should begin with "jdbcdbc:") :

      String url = "jdbc:odbc:connector-j";
      Connection con = DriverManager.getConnection(url, user, pass);
    what should I write in url? localhost? connector-j? mysql?

    Also, I've uncompressed Connector-J but couldn't get the jar file running (no manifest something problem)...
    Last edited by dhakir; 12-03-2005 at 09:21 AM.

  4. #4
    Join Date
    Mar 2004
    Here's how I connect to mine, where the sql server is on another machine on my network. It then stores the name of all the databases found into a vector. If you don't specify a database at connection time (like i have), you need that last "/" at the end of the address or you'll get a "driver cannot be found" error.
    Vector databases = new Vector();
    String host = "";
    String user = "foo";
    String pass = "bar";
                String url = "jdbc:mysql://"+host;
                connection = DriverManager.getConnection(url, user, pass);
                DatabaseMetaData dbmd = connection.getMetaData();
                ResultSet result = dbmd.getCatalogs();
                ResultSet result = dbmd.getCatalogs();
    catch(Exception e)
    You shouldn't run the driver jar file, just put it in the "ext" directory of where the jsdk is installed.

  5. #5
    Join Date
    Dec 2004
    Thanks, I think I've managed to do something by setting the classpath. In fact, I cannot change the ext folder because I don't have permission.

    But is there a way to do it without using Connector/J? Like using some standard generic driver (maybe something related to ODBC)?

  6. #6
    Join Date
    Mar 2004
    I cannot change the ext folder because I don't have permission.
    I ran into that problem the other day when installing the driver on my mac. had to log in as root.

    There's not native driver included with jsdk that I'm aware of.

Similar Threads

  1. JDBC configuration in Linux
    By manoj nahar in forum Database
    Replies: 0
    Last Post: 03-07-2002, 01:11 AM
  2. java jdbc connection on w2k, Oracle8i, JDK1.3
    By frest in forum oracle.general
    Replies: 0
    Last Post: 05-01-2001, 07:33 AM
  3. MS SQL Server and JDBC
    By CH in forum Java
    Replies: 5
    Last Post: 04-18-2001, 03:59 PM
  4. Wierd JDBC behaviour
    By Fabio Luis De Paoli in forum Java
    Replies: 2
    Last Post: 01-15-2001, 02:33 PM
  5. JDBC Newbie
    By Saiful in forum Java
    Replies: 3
    Last Post: 09-28-2000, 05:22 AM

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.