开发者

Hibernate fails to open Connection with Oracle 11g?

I made a basic JUnit test to set up this Oracle database on my computer with hibernate. The database works and everything, but trying to hook it up to Hibernate is proving to be a challenge. My config file can be here:

The JUnit test is fairly straight forward and I'm sure it should work, but I'm getting this JUnit failure:

org.hibernate.exception.JDBCConnectionException: Cannot open connection

Any ideas what's wrong with it?

Connection properties in Hibernate config file:

<session-factory>
    <property name="hibernate.connection.driver_class">
        oracle.jdbc.OracleDriver</property>
    <property name="开发者_如何转开发hibernate.connection.url">
        jdbc:Oracle:thin:@127.0.0.1:8080/slyvronline</property>
    <property name="hibernate.connection.username">
        YouNoGetMyLoginInfo</property>
    <property name="hibernate.connection.password">
        YouNoGetMyLoginInfo</property>
    <property name="dialect">
        org.hibernate.dialect.OracleDialect</property>
    <!-- Other -->
    <property name="show_sql">true</property>
    <property name="hibernate.hbm2ddl.auto">validate</property>

    <!-- Mapping files -->
    <mapping class="com.slyvr.pojo.Person"/>
</session-factory>


It's unlikely (but possible) your DB is listening on port 8080. Oracle defaults to port 1521. Start there.

(Since it's a connection issue, relevant portions of Hibernate config are useful; I've edited to reflect.)


There are possible two issues in your connection string

first is the port that Dave Newton, second that after port you should add the sid after : not /.

So try this as a solution:

jdbc:Oracle:thin:@127.0.0.1:1521:slyvronline


When you are connecting with oracle, no need to mention the schema name so the connection URL looks like as below

    jdbc:oracle:thin:@<hostname>:<port>:<sid>
    ex:
    jdbc:oracle:thin:@localhost:1521:xe
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜