File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes please help in setting db connection in jboss Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "please help in setting db connection in jboss" Watch "please help in setting db connection in jboss" New topic
Author

please help in setting db connection in jboss

rubbal sandhu
Greenhorn

Joined: Dec 20, 2010
Posts: 7
I have a WAR file which runs fine on IBM websphere, now I want to run it on jboss. I am able to run a static website by putting it in the deploy folder, but for the dynamic website I need to make an oracle connection. Can any one please help where all I need to make changes. I am not using EJB's do I still need jbosscmp-jdbc.xm?

Regards
uttam kumar
Ranch Hand

Joined: Jan 27, 2009
Posts: 128

Which JBoss version you are using? For making a connection with database you have to deploy a corresponding *-ds.xml file. See <JBOSS_HOME>\docs\examples\jca.
rubbal sandhu
Greenhorn

Joined: Dec 20, 2010
Posts: 7
uttam kumar wrote:Which JBoss version you are using? For making a connection with database you have to deploy a corresponding *-ds.xml file. See <JBOSS_HOME>\docs\examples\jca.


Thanks!!
I am using jboss 5.0.0 I have made changes in hsqldb-ds.xml and standardjbosscmp-jdbc.xml, do I need to make any change in my war file as well
uttam kumar
Ranch Hand

Joined: Jan 27, 2009
Posts: 128

You need to deploy oracle-ds.xml for making connection with oracle database. No need to change hsqldb-ds.xml. Are you facing any kind of error while deploying you war? If so, please post the entire error log along with the changes that you have done in JBoss.

Thanks,
Uttam Kumar
rubbal sandhu
Greenhorn

Joined: Dec 20, 2010
Posts: 7
Hi
I am sorry but I am new to jboss, do I need to have oracle-datasource.xml in my WAR file?
Among the long error logs, 'jdbc not bound' caught my eye.
I have made following changes in jboss:
in default/deploy/ hsqldb-ds.xml
I have added,

<jndi-name>jdbc/MYCoreDS</jndi-name>
<connection-url>jdbcracle:thin:@192.166.6.115:1521:MYDB</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>

<!-- The login and password -->
<user-name>m_demo</user-name>
<password>m_demo</password>

and in default/conf/ standardjbosscmp-jdbc.xml
<datasource>java:/MYCoreDS</datasource>
I have taken the above elements from datasource file produced by my jdev
Also I have put classes12.jar in jboss lib folder and also in my WAR file.


uttam kumar wrote:You need to deploy oracle-ds.xml for making connection with oracle database. No need to change hsqldb-ds.xml. Are you facing any kind of error while deploying you war? If so, please post the entire error log along with the changes that you have done in JBoss.

Thanks,
Uttam Kumar
uttam kumar
Ranch Hand

Joined: Jan 27, 2009
Posts: 128

Rub sandhu wrote:do I need to have oracle-datasource.xml in my WAR file?

You need to put oracle-ds.xml into <JBOSS_HOME>\server\<SERVER_TYPE>\deploy and corresponding required jar (eg: ojdbc14.jar) into <JBOSS_HOME>\server\<SERVER_TYPE>\lib folder.

Rub sandhu wrote:
I have made following changes in jboss:
in default/deploy/ hsqldb-ds.xml
I have added,

<jndi-name>jdbc/MYCoreDS</jndi-name>
<connection-url>jdbcracle:thin:@192.166.6.115:1521:MYDB</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>

<!-- The login and password -->
<user-name>m_demo</user-name>
<password>m_demo</password>

and in default/conf/ standardjbosscmp-jdbc.xml
<datasource>java:/MYCoreDS</datasource>

No need to modify hsqldb-ds.xml or standardjbosscmp-jdbc.xml. There are other services which uses jndi defined in hsqldb-ds.xml. Either you make changes everywhere or better leave it alone.
rubbal sandhu
Greenhorn

Joined: Dec 20, 2010
Posts: 7
Hi Uttam,

Thanks for your help.
I have put the oracle-ds.xml file in the server\default\deploy
also I have tried putting both ojdbc.jar and classes12.jar in server\default\lib

I am still getting javax.naming.NameNotFoundException: jdbc not bound

here is my oracle-ds.xml file

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

<!-- ===================================================================== -->
<!-- -->
<!-- JBoss Server Configuration -->
<!-- -->
<!-- ===================================================================== -->

<!-- $Id: oracle-ds.xml,v 1.6 2004/09/15 14:37:40 loubyansky Exp $ -->
<!-- ==================================================================== -->
<!-- Datasource config for Oracle originally from Steven Coy -->
<!-- ==================================================================== -->


<datasources>
<local-tx-datasource>
<jndi-name>MYCoreDS</jndi-name>
<connection-url>jdbcracle:thin:@192.166.6.115:1521:MYDB</connection-url>
<!--
See on WIKI page below how to use Oracle's thin JDBC driver to connect with enterprise RAC.
-->
<!--
Here are a couple of the possible OCI configurations.
For more information, see http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/toc.htm

<connection-url>jdbcracleci:@youroracle-tns-name</connection-url>
or
<connection-url>jdbcracleci:@(description=(address=(host=youroraclehost)(protocol=tcp)(port=1521))(connect_data=(SERVICE_NAME=yourservicename)))</connection-url>

Clearly, its better to have TNS set up properly.
-->
<driver-class>oracle.jdbc.pool.OracleDataSourcer</driver-class>
<user-name>m_demo</user-name>
<password>*****</password>

<min-pool-size>5</min-pool-size>
<max-pool-size>100</max-pool-size>

<!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
<!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
<!-- Checks the Oracle error codes and messages for fatal errors -->
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->

<!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
-->

<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</local-tx-datasource>

</datasources>




uttam kumar
Ranch Hand

Joined: Jan 27, 2009
Posts: 128

model.DBConnector.getDBConnection(DBConnector.java:36)

Looks like in your code, you are searching for JNDI with prefix as "jdbc". Try changing the code. See if it works or not.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: please help in setting db connection in jboss