-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Can't open a connection with Oracle and OC4J
PostPosted: Thu Mar 20, 2008 1:57 pm 
Newbie

Joined: Wed Feb 20, 2008 10:53 am
Posts: 15
I can't open a connection. Here is my info:



Hibernate version: 3.2

Mapping documents:

OC4J data-sources.xml

<?xml version = '1.0' standalone = 'yes'?>
<data-sources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/data-sources-10_1.xsd" schema-major-version="10" schema-minor-version="1">

<managed-data-source name="SID"
connection-pool-name="HibernateConnection"
jndi-name="hibernate/OracleDS"
user="user"
password="password"/>

<connection-pool name="HibernateConnection" disable-server-connection-pooling="false" validate-connection="false" abandoned-connection-timeout="1" time-to-live-timeout="1" connection-retry-interval="1" inactivity-timeout="60" initial-limit="5" login-timeout="10" max-connect-attempts="5" max-connections="5" min-connections="2" used-connection-wait-timeout="60" num-cached-statements="10" property-check-interval="900">
<connection-factory
factory-class="oracle.jdbc.pool.OracleDataSource"
user="user"
password="password"
login-timeout="10"
url="jdbc:oracle:thin:@192.168.132.92:2224:sid">
</connection-factory>
</connection-pool>

</data-sources>


hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0 //EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="connection.datasource">hibernate/OracleDS</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
<mapping resource="business/MemberList.hbm.xml"/>
</session-factory>

</hibernate-configuration>




Code between sessionFactory.openSession() and session.close():

Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
MemberList memberList = new MemberList();
memberList.setDateEntered(new Timestamp(new java.util.Date().getTime()));
memberList.setEmail(email);
memberList.setFirstName(first);
memberList.setLastName(last);
memberList.setZip(zip);
session.save(memberList);
session.getTransaction().commit();
out.println("Member added. Thank you.<br/>");
Query query = session.createQuery("from MemberList");
List members = query.list();
out.println("<table cellspacing='5' border='1'><tr><th>First Name</th><th>Last Name</th>");
out.println("<th>Zip</th><th>Email</th><th>Date Entered</th></tr>");
Iterator i = members.iterator();
while (i.hasNext()) {
MemberList m = (MemberList) i.next();
out.println("<tr>");
out.println("<td>" + m.getFirstName() + "</td>");
out.println("<td>" + m.getLastName() + "</td>");
out.println("<td>" + m.getZip() + "</td>");
out.println("<td>" + m.getEmail() + "</td>");
out.println("<td>" + sdf.format(m.getDateEntered()) + "</td>");
out.println("</tr>");
}
out.println("</table>");
session.close();



Full stack trace of any exception that occurs:

org.hibernate.exception.GenericJDBCException: Cannot open connection at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426) at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144) at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119) at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57) at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326) at business.PersistMemberListServlet.doPost(PersistMemberListServlet.java:48) at javax.servlet.http.HttpServlet.service(HttpServlet.java:763) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:122) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:111) at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303) at java.lang.Thread.run(Thread.java:595)Caused by: java.sql.SQLException: Connection Cache with this Cache Name is Disabled at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:240) at oracle.jdbc.pool.OracleImplicitConnectionCache.getConnection(OracleImplicitConnectionCache.java:310) at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:286) at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:179) at oracle.oc4j.sql.DataSourceConnectionPoolDataSource.getPooledConnection(DataSourceConnectionPoolDataSource.java:87) at oracle.oc4j.sql.xa.EmulatedXADataSource.getXAConnection(EmulatedXADataSource.java:117) at oracle.oc4j.sql.spi.ManagedConnectionFactoryImpl.createXAConnection(ManagedConnectionFactoryImpl.java:209) at oracle.oc4j.sql.spi.ManagedConnectionFactoryImpl.createManagedConnection(ManagedConnectionFactoryImpl.java:170) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.connector.ApplicationConnectionManager.createManagedConnection(ApplicationConnectionManager.java:1377) at oracle.j2ee.connector.ConnectionPoolImpl.createManagedConnectionFromFactory(ConnectionPoolImpl.java:327) at oracle.j2ee.connector.ConnectionPoolImpl.access$800(ConnectionPoolImpl.java:98) at oracle.j2ee.connector.ConnectionPoolImpl$NonePoolingScheme.getManagedConnection(ConnectionPoolImpl.java:1211) at oracle.j2ee.connector.ConnectionPoolImpl.getManagedConnection(ConnectionPoolImpl.java:785) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.connector.ApplicationConnectionManager.getConnectionFromPool(ApplicationConnectionManager.java:1575) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.connector.ApplicationConnectionManager.acquireConnectionContext(ApplicationConnectionManager.java:1520) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.connector.ApplicationConnectionManager.allocateConnection(ApplicationConnectionManager.java:1465) at oracle.j2ee.connector.OracleConnectionManager.unprivileged_allocateConnection(OracleConnectionManager.java:238) at oracle.j2ee.connector.OracleConnectionManager.allocateConnection(OracleConnectionManager.java:192) at oracle.oc4j.sql.ManagedDataSource.getConnection(ManagedDataSource.java:272) at oracle.oc4j.sql.ManagedDataSource.getConnection(ManagedDataSource.java:200) at oracle.oc4j.sql.ManagedDataSource.getConnection(ManagedDataSource.java:142) at oracle.oc4j.sql.ManagedDataSource.getConnection(ManagedDataSource.java:127) at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:69) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423) ... 17 more




Name and version of the database you are using: Oracle9i


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 23, 2008 3:07 am 
Beginner
Beginner

Joined: Fri Sep 08, 2006 7:29 am
Posts: 36
Have you tried providing username passowrd in the hibernate.cfg.xml. Even I am a bit surprised....but somehow it works like that...

_________________
Shardul
Please Rate.


Top
 Profile  
 
 Post subject: Solved it somehow
PostPosted: Fri Apr 25, 2008 9:12 pm 
Newbie

Joined: Wed Feb 20, 2008 10:53 am
Posts: 15
I figured this out a couple months ago but I don't remember how anymore. Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.