My application is using Spring 4, Hibernate 4, Java 1.7. This is a desktop application rather than a web application, so there is no server involved. I'm trying to create a connection to the database. For brevity's sake--I can't copy and paste--I left out some non-essential stuff to the problem. Here's my spring config:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="oracle.jdbc.OracleDriver" />
<property name="jdbcUrl" value="jdbc:oracle:thin:@dbServer:1521:service" />
<property name="properties">
<props>
<prop key="user">user</prop>
<prop key="password">password</prop>
</props>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.help.please" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.connection.autocommit">true</prop>
</props>
</property>
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
I have the sessionFactory
autowired into a DAO. When I try to obtain a connection from the sessionFactory
, the logs look like so (again, shortened):
INFO [main] C3P0Registry:216 Initializing c3p0-0.9.2.1 [built 20-March-2013 10:47:27 +0000; debug? true; trace: 10]
INFO [main] Version:66 - HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
INFO [main] Version:54 - HHH000412: Hibernate Core {4.3.8.Final}
INFO [main] Environment:224 - HHH000205: Loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.h2.Driver, hibernate.service.allow_crawling=false, hibernate.dialect=org.hibernate.dialect.H2Dialect, hibernate.max_fetch_depth=5, hibernate.format_sql=true, hibernate.generate_statistics=true, hibernate.connection.username=sa, hibernate.connection.url=jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE, hibernate.bytecode.use_reflection_optimizer=false, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=5}
INFO [main] Environment:346 - HHH000021: Bytecode provider name : javassist
INFO [main] AbstractPoolBackedDataSource:522 - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailer -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> [mumbo jumbo], debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> [mumbo jumbo], idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:oracle:thin:@dbServer:1521:service, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, preferredTestQuery -> null, properties -> {user=****, password=********}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
WARN [main] JdbcServicesImpl:204 - HHH000342: Could not obtain connection to query metadata : ORA-01017: invalid username/password; logon denied
I am successfully able to use the user to login to the database using other applications as well as SQL Developer. I've made sure multiple times that the user/password is correct. I've tried using both ojdbc6.jar
and ojdbc7.jar
in hopes that it might be that. I've done some research and saw that it might be that the username/password might be automatically being capitalized before being sent to Oracle, but I know of know way of verifying that.
A note that might be important is that this code was connecting to the database just fine when I was using Spring 3 and Hibernate 3. Any suggestions as to how I can fix this problem?
EDIT
It's important to note that I'm using a combination of annotations and xml to configure my project. I'm using @Autowired
to inject my services, daos, and session factory. I'm using @Transactional
and @Repository
in my dao layer. I don't know if that makes a difference or not, but please see my answer below to see how I got it working.