It's not a secret anymore!*
The moose likes JBoss/WildFly and the fly likes Defining Datasource in JBoss4.x Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Defining Datasource in JBoss4.x" Watch "Defining Datasource in JBoss4.x" New topic
Author

Defining Datasource in JBoss4.x

Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
Hi
In which file in JBoss can I define my own datasource for MySQl database,and what varions properties I have set?
Patricia Samuel
Ranch Hand

Joined: Sep 12, 2007
Posts: 300
<?xml version="1.0" encoding="UTF-8"?>

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

<!-- ==================================================================== -->
<!-- Datasource config to be copied in Location where to keep this file jboss-4.0.4.GA\server\default\deploy -->
<!-- ==================================================================== -->


<datasources>
<local-tx-datasource>
<jndi-name>jdbc/testDS</jndi-name>
<connection-url>jdbc racle:thin:@url:1521:schema</connection-url>
<driver-class>driver class - jdbc.</driver-class>
<user-name>user</user-name>
<password>password</password>
<!-- 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>
<check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>

</local-tx-datasource>

</datasources>



Name this file after the name of your project. Like if your project name is test then name it like testDS.
and keep this file under location - \jboss-4.0.4.GA\server\default\deploy

Hope this would help. If you face any problem, kindly post a comment.
[ October 27, 2008: Message edited by: Patricia Samuel ]
Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
Thanks for early reply,but where can i find this datasource config file and what is the name of that file to be copied?
Thanks
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9915
    
158

See these wiki articles:

Config DataSources

-ds.xml

You can find example datasource files in %JBOSS_HOME%\docs\examples\jca folder.


[My Blog] [JavaRanch Journal]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Defining Datasource in JBoss4.x
 
Similar Threads
Getting GenericJDBCException
J2ee application and JNDI in a Servlet
How to integrate SQL server with JBOSS
Struts Connection pool (please help)
Isolation Level