I have a sample program. It works if I use JDBC connection. But when I change to JNDI, it failed. See the error massage below. My JNDI is definitely works since it is used by another program. Please see what is wrong with my hibernate code.
hibernate.cfg.xml, mapping xml and program code are included below.
Thanks for help.
lijao
Hibernate version: 2.1.7
Mapping documents:
hibernate.cfg.xml
<property name="connection.datasource">jdbc/sybDB</property>
<!--
<property name="connection.driver_class">com.sybase.jdbc2.jdbc.SybDriver</property>
<property name="connection.url">jdbc:sybase:Tds:ise-devel8:5000/FNFCM_D</property>
-->
<property name="dialect">net.sf.hibernate.dialect.SybaseDialect</property>
<property name="connection.username">sa</property>
<property name="connection.password">sa</property>
<property name="show_sql">true</property>
------------------------
CD.hbm.xml
<hibernate-mapping>
<class name="CD" table="cm_client">
<id name="id" type="big_decimal" column="cm_client_number">
<generator class="native"/>
</id>
<timestamp column="cm_modify_date" name="purchasedate" unsaved-value="null"/>
<property name="title" column="cm_mother_maiden_name" type="string" not-null="false"/>
<property name="artist" column="cm_birth_name" type="string" not-null="false"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
session = sessionFactory.openSession();
List cds = session.find("from CD");
Iterator iter = cds.iterator();
while (iter.hasNext()) {
CD cd = (CD)iter.next();
out.println("<tr><td>");
out.println(cd.getId());
out.println("</td><td>");
out.println(cd.getArtist());
out.println("</td><td>");
out.println("no value");
out.println("</td></tr>");
}
}
session.flush();
session.close();
Full stack trace of any exception that occurs:
[4/18/05 13:53:05:688 PDT] 1088ffcf DatasourceCon I net.sf.hibernate.connection.DatasourceConnectionProvider Using datasource: jdbc/sybDB
[4/18/05 13:53:05:703 PDT] 1088ffcf TransactionMa I net.sf.hibernate.transaction.TransactionManagerLookupFactory No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
[4/18/05 13:53:06:109 PDT] 1088ffcf FreePool E J2CA0046E: Method createManagedConnctionWithMCWrapper caught an exception during creation of the ManagedConnection for resource jdbc/sybDB, throwing ResourceAllocationException. Original exception: com.ibm.ws.exception.WsException: DSRA8100E: Unable to get a PooledConnection from the DataSource.
at com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.<init>(DataStoreAdapterException.java:244)
at com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException.<init>(DataStoreAdapterException.java:171)
at com.ibm.ws.rsadapter.AdapterUtil.createDataStoreAdapterException(AdapterUtil.java:191)
at com.ibm.ws.rsadapter.DSConfigurationHelper.getPooledConnection(DSConfigurationHelper.java:694)
at com.ibm.ws.rsadapter.spi.WSRdbDataSource.getPooledConnection(WSRdbDataSource.java:440)
at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.createManagedConnection(WSManagedConnectionFactoryImpl.java:566)
Name and version of the database you are using: Sybase 12
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
|