Saya sedang menulis program Hibernate sederhana dengan Oracle sebagai database.
Saya menghadapi kesalahan ini dan saya tidak bisa mendapatkan solusi meskipun banyak percobaan.
Saya telah menambahkan semua toples hibernasi & Oracle(ojdbc14.jar)
Saya memiliki skema sebagai "tes" di database Oracle
Nama pengguna & kata sandi untuk Oracle adalah sistem

Saya telah membuat file-file berikut:

  1. Student.java - kelas POJO dengan field sebagai rollno, nama, alamat & setter/getter
  2. Student.hbm.xml - File pemetaan
  3. Student.cfg.xml - File Konfigurasi Hibernasi
  4. Test.java - Kelas driver

Student.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.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name = "connection.url">jdbc:oracle:thin:@localhost:1521:xe</property>
        <property name = "username">system</property>
        <property name = "password">system</property>

        <property name = "show_sql">true</property>
        <property name = "dialect">org.hibernate.dialect.OracleDialect</property>
        <property name = "hbm2ddl.auto">update</property>

        <mapping resource = "com/alighthub/Student.hbm.xml"/>
    </session-factory>

    </hibernate-configuration>

Di bawah ini adalah kesalahannya:

    Exception in thread "main" 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:420)
        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 com.alighthub.Test.main(Test.java:16)
    Caused by: java.sql.SQLException: invalid arguments in call
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:236)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
        at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
        at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417)
        ... 5 more

Silakan menyarankan.

0
CoderDS 10 November 2017, 13:24

1 menjawab

Jawaban Terbaik

Properti untuk nama pengguna & kata sandi salah di Student.cfg.xml, diperbarui sebagai "connection.username" & "connection.password" seperti di bawah ini: -

    <property name = "connection.username">system</property>
    <property name = "connection.password">system</property>
0
CoderDS 10 November 2017, 11:02