To connect glassfish to a database, is raccomanded setup jndi data source by command line.
In order to have the setup you shoud follow this steps
Create a Connection pool
to create a connection pool you can use the command create-jdbc-connection-pool as follow
create-jdbc-connection-pool --datasourceclassname oracle.jdbc.xa.client.OracleXADataSource --restype javax.sql.XADataSource --property portNumber=1521:user=CARDIO_USR:password=CARDIO_USR:serverName=localhost:databaseName=xe:drivertype=thin:connectionAttributes=\;create\\=true HRPool
You can do the same thing usning jdbc connection url
create-jdbc-connection-pool --datasourceclassname
oracle.jdbc.xa.client.OracleXADataSource --restype
javax.sql.XADataSource --property
password=HR:user=HR:url="jdbc\:oracle\:thin\:@//localhost\:1521/xe":connectionAttributes=\;create\\=true
HRPool
Create a JNDI reference to the connection
to create a jndi resource for the connection use this command
create-jdbc-resource --connectionpoolid HRPool jdbc/HRDS
Autocommit manage
you can disable autocommit on created connection. You can do that from the administrative consoleConfiguration -> server-config -> JVM Settings -> JVM Options
-Doracle.jdbc.autoCommitSpecCompliant=false
N.B.
all this configurations are store on:<Glassfish_path>\glassfish\domains\domain1\config\domain.xml
No comments:
Post a Comment