JDBC with OUT DriverManager

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bergy
    New Member
    • Mar 2007
    • 89

    #1

    JDBC with OUT DriverManager

    I am writing on an embedded device (J9 framework from IBM) that has a partial version of the java.sql package. It does not include Driver or DriverManager. I have downloaded the mysql Connector/J but all of their examples use the DriverManager. Something like:

    Code:
    conn = DriverManager.getConnection("jdbc:mysql://localhost/test?" + 
                                       "user=monty&password=greatsqldb");
    Does anyone know of any modules that can connect to MySQL without the use of the JDBC driver manager?

    Just in case someone asks, the classes I have access to are:

    java.sql.BatchU pdateException
    java.sql.Blob
    java.sql.Callab leStatement
    java.sql.Clob
    java.sql.Connec tion
    java.sql.Databa seMetaData
    java.sql.DataTr uncation
    java.sql.Date
    java.sql.Prepar edStatement
    java.sql.Result Set
    java.sql.Result SetMetaData
    java.sql.Savepo int
    java.sql.SQLExc eption
    java.sql.SQLWar ning
    java.sql.Statem ent
    java.sql.Time
    java.sql.Timest amp
    java.sql.Types
    ---------
    javax.sql.DataS ource
    javax.sql.RowSe t
    javax.sql.RowSe tEvent
    javax.sql.RowSe tInternal
    javax.sql.RowSe tListener
    javax.sql.RowSe tMetaData
    javax.sql.RowSe tReader
    javax.sql.RowSe tWriter
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Not sure if this is right for you but, how 'bout:

    mysql data - Google Search

    Just some fancy links; if you have already seen these, do come back and ask more questions.

    In a bit

    Comment

    • bergy
      New Member
      • Mar 2007
      • 89

      #3
      I appreciate the bump of the thread, but honestly did you read my post? I know how to use MySQL or I would be posting in those forums. This is a specific Java related question, related to specific java packages - I fail to see how just searching mysql data in Google would return anything about java. Let me re-explain:

      Normally, in java, you use a class called DriverManager and Driver to load the MySQL or any other JDBC driver. I'm asking if anyone knows of a work around that does not use DriverManager or Driver because the device I'm using does not include it as part of the JRE.

      Sorry about the tone, but I've been researching this (via Google among other resources) for a day or two and haven't found anything. I too don't get a little annoyed when people post with out checking Google first, but I assure you this is not one of of those posts :P

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        I see the DataSource interface; is there a way to obtain a DataSource implementation?

        kind regards,

        Jos

        Comment

        • bergy
          New Member
          • Mar 2007
          • 89

          #5
          Thanks for the reply Josah; I have tried using "com.mysql.jdbc .jdbc2.optional .MysqlConnectio nPoolDataSource " and "com.mysql.jdbc .jdbc2.optional .MysqlDataSourc e" but both seem to call java.sql.Driver at some point as I'm still getting the error java.lang.NoCla ssDefFoundError : java.sql.Driver

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by bergy
            Thanks for the reply Josah; I have tried using "com.mysql.jdbc .jdbc2.optional .MysqlConnectio nPoolDataSource " and "com.mysql.jdbc .jdbc2.optional .MysqlDataSourc e" but both seem to call java.sql.Driver at some point as I'm still getting the error java.lang.NoCla ssDefFoundError : java.sql.Driver
            You shouldn't need to know about these classes. All you want is an implementation of a DataSource interface. Do you have any naming services available on your device? e.g. JNDI can hand out DataSources ...

            kind regards,

            Jos

            Comment

            • bergy
              New Member
              • Mar 2007
              • 89

              #7
              As far as I know there are no naming services, unless you count the framework's built in one which in this case won't work (as far as I can gather). There is some class introspection done at runtime that is finding the private? Driver variable in the MySQL DataSource class. I have decided to write a PHP script on the database server that I can just query using HTTP/XML. Not really the route I wanted to go but I think it's my only option at this point.

              Since the code that I'm writing can still run in a normal JRE I'm leaving the DriverManager stuff in there for that situation - what I'm wondering is if there is an easy way to populate a ResultSet object with my own data that is being parsed from the XML so I can handle them the same way regardless of how I'm connecting to MySQL.
              Last edited by bergy; Jan 7 '09, 02:03 AM. Reason: Edited for Clarification

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                I don't understand the availability of the javax.sql.DataS ource interface then. If there is no DriverManager (nor a Driver) and you can't use that DataSource then all the other classes are moot, i.e. you can't use them. We must be missing something here ...

                kind regards,

                Jos

                Comment

                • JosAH
                  Recognized Expert MVP
                  • Mar 2007
                  • 11453

                  #9
                  I googled a bit more and found that J9 is a bit of a strange beast: i.e. IBM's own DB2 runs fine on it using ordinary JDBC and a DataSource; HSQLDB also seems to run fine but Sun's own Apache Derby implementation doesn't run and Oracle's DB also seems to have some problems. MySQL isn't even mentioned in all the complaint stories ...

                  kind regards,

                  Jos

                  Comment

                  • bergy
                    New Member
                    • Mar 2007
                    • 89

                    #10
                    Yes, it's quite annoying, you would think that by now, this type of thing on an embedded device would be a no brainer, but I guess not for IBM >< Thanks for your help J!

                    Comment

                    Working...