5 Replies Latest reply on Apr 25, 2002 1:17 AM by Christoph Grimm

    New in jdbc

    Alexandre Bouchard Newbie

      Hi all!

      I have to connect to an SQL Server database and I just don't know where to start! I downloaded a JDBC driver for SQL Server but don't know what to do now! Any help will be very appreciated!

      Thank's

        • 1. Re: New in jdbc
          Joel Schuster Newbie

          Two steps,
          One: define the connection pool:
          Take a look at these working examples for other databases. All you really need to know is the URI and driver.
          http://www.jboss.org/online-manual/HTML/ch03s12.html

          Two: make the resource available to your application:
          http://www.jboss.org/online-manual/HTML/ch07s02.html

          • 2. Re: New in jdbc
            Alexandre Bouchard Newbie

            The problem is that those steps are for version 3 of JBoss and I'm using version 2.4...

            > Two steps,
            > One: define the connection pool:
            > Take a look at these working examples for other
            > databases. All you really need to know is the URI and
            > driver.
            > http://www.jboss.org/online-manual/HTML/ch03s12.html
            >
            > Two: make the resource available to your
            > application:
            > http://www.jboss.org/online-manual/HTML/ch07s02.html

            • 3. Re: New in jdbc
              Christoph Grimm Newbie

              1. put your jdbc driver in jboss/lib/ext directory

              2. open your jboss.jcml config file
              either the one in jboss/conf/default or the one in jboss/conf/catalina ( depends omn wheter you start with embedded catalina or not )

              3. specify your jdbc driver, therefore search for the following
              "org.jboss.jdbc.JdbcProvider"

              you will find an entry like this

              org.hsqldb.jdbcDriver


              cut and paste below

              replace "DefaultDomain" with "MSSQLDomain"
              replace "org.hsqldb.jdbcDriver" with your jdbc driver class.

              4. specify a datasource for your database, therefore search for the following: "org.jboss.jdbc.XADataSourceLoader"

              you will find this:


              DefaultDS
              org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl

              jdbc:hsqldb:hsql://localhost:1476
              1200000
              sa
              10

              false
              false
              false
              true
              120000
              1800000
              false
              false
              1.0
              0



              cut and paste below

              replace "DefaultDomain" with "MSSQLDomain"
              replace "DefaultDS" with "MSSQL_DS"
              replace the URL attribute with the mssql driver url -> look in the driver doc for details

              replace the user attribute with your database user name
              if your database requires a password, extend the password attribute tag:
              ...your...password..

              _______

              now you have a datasource named "MSSQL_DS"

              to use it with CMP Beans put your own jaws.xml in the META-INF directory
              of your ejb jar

              the jaws.xml should have at least the following content:

              <?xml version="1.0" encoding="UTF-8"?>

              java:/MSSQL_DS

              • 4. Re: New in jdbc
                Alexandre Bouchard Newbie

                Thank you very much! It's work perfectly for the connection! The only problem I have now is that when I execute a query, I get an exception telling me the table could not be found. But I know that the table exist in the database...very strange

                • 5. Re: New in jdbc
                  Christoph Grimm Newbie

                  i have no experience with ms sql server at all
                  if msq sql server supports meta data
                  you can find out what tables you have in the schema by using
                  connection.getMetaData().getTables( null,null,null,"TABLE")

                  look in the java api doc java.sql.Connection for details