how to access sql database from j2ee server(URGENT)

Discussions

EJB programming & troubleshooting: how to access sql database from j2ee server(URGENT)

  1. I am getting the problem while am trying to connect the MS SQL server from j2ee server.

    I followed the configuration doc to configure the config/default.properties file and he is asking to install driver.jar into lib/systems directory.where do i get this driver.jar and i want, correct configuration for sql to be palced in the config/default.properties file.

    if possible send for Oracle also

    Expecting reply soon

    thank u

     

  2. Hi Nagul,
    U need to download the Sequelink driver from the Merant site,i-e, www.merant.com

    Wish u all the best.
    Bye.

    Regards,
    Shibin
  3. Hi,

    I think connecting MS SQL Server from J2EE rather simple execise. I did the following in my NT Server and it was functioning well:
    1. Create 32 bit data source name, say, "xserver" using control panel
    2. in j2sdkee1.2.1\config\default.properties:
      a. jdbc.drivers=sun.jdbc.odbc.JdbcOdbcDriver
      b. jdbc.datasources=jdbc/MyServer|jdbc:odbc:xserver;create=true
    3. In Deployment Tool provide jdbc/MyServer for JNDI name

    Regards
    Subahsh
  4. Hi Subash,
     Could u please explain the folowing line:

    jdbc.datasources=jdbc/MyServer|jdbc:odbc:xserver;create=true

    What does this 'jdbc:odbc:xserver' exactly stand for???

    Thanking u in advance,
    Shibin
  5. Hi,

    'xserver' stands for the data source name created for the SQL Server database name called XYZDatabase. In NT server, using 32Bit odbc data source administrator, you can create this name (Start->Settings->ControlPanel->32BitODBC). You map this name to the JNDI name in the default.properties file. jdbc.drivers=sun.jdbc.odbc.JdbcOdbcDriver will take care of the bridging. You may not require any other resources to make SQL Server database available for J2EE Application. Hope this clarifies.

    Regards
    Subhash
  6.  Thanx Subash.
    So, the xserver part is ok. Now, what about the MyServer part? I guessits the jndi name. But, is this anywhere used in the codes of ur program???
    Could u please just explain the implementation of one example(Account example from J2EE documentation)...I mean just the steps needed to be done for its implementation/deployment.

    Regards,
    Shibin
  7. Hi Subash,

     In the documentation it is stated that the jar file for the database driver must be kept in the 'systems' folder.
    So, what should I keep in the systems folder for the above case that u have mentioned????

    Regards,
    Shibin
  8. hi shibin,

    Even i downloaded the Sequelink driver from merant site,i kept in lib/systems directory and I configured the config/default.properties file

    still getting problem,

    please keep inform me if u get the solution

    thank u

    regads
    sivaraju
  9. hi shibin,

    Even i downloaded the Sequelink driver from merant site,i kept in lib/systems directory and I configured the config/default.properties file

    still getting problem,

    please keep inform me if u get the solution

    thank u

    regads
    sivaraju
  10. Hi,

    No jar file is required. That is how I did, in my NT system.

    Regards
    Subhash
  11. I did it exactly the same as you, but it still doesn't work. In the error.log file, it says:
    javax.ejb.EJBException: Unable to connect to database. No suitable driver
    at AccountEJB.setEntityContext(AccountEJB.java:155)
    at com.sun.ejb.containers.EntityContainer.getPooledEJB(EntityContainer.java:834)
    at com.sun.ejb.containers.EntityContainer.getContext(EntityContainer.java:186)
    at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:273)
    at AccountHomeImpl.create(AccountHomeImpl.java:18)
    at _AccountHomeImpl_Tie._invoke(Unknown Source)
    at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatchToServant(GenericPOAServerSC.java:423)
    at com.sun.corba.ee.internal.POA.GenericPOAServerSC.internalDispatch(GenericPOAServerSC.java:137)
    at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatch(GenericPOAServerSC.java:98)
    at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:227)
    at com.sun.corba.ee.internal.iiop.CachedWorkerThread.doWork(IIOPConnection.java:262)
    at com.sun.corba.ee.internal.iiop.CachedWorkerThread.run(IIOPConnection.java:230)

    Can anybody tell me what's wrong?

    Thanks.
  12. hi Subhash,
    I followed the steps that you mentioned exactly.Still I get
    the following error in the command prompt window where I started j2ee server.I'm using SQL server

    java:comp\env\jdbc\AccountDB is using a JNDI name that is not bound jdbc\MyServer

    Also I'm getting another error when I try to run the client.

    java.lang.ClassCastException at com.sun.corba.ee.internal.javax.rmi.PortableRemoteObject.narrow()

    Please reply as soon as possible.

    Thanks in advance,
    chandana