如何在Oracle中插入非英语数据。我试过下面的代码,在插入数据之前是印地语。
Worker POJO class
@Column(name = "name", columnDefinition = "VARCHAR2(255)")
private String name;
//getter and setter
Insert
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
Transaction tx= null;
try { tx = session.beginTransaction();
Worker w = new Worker;
w.setName = "मनीषा";
System.out.println(w.getName()) // Prints the data in hindi
session.save(Worker);
}
tx.commit();
//Catch block
当我从数据库中选择记录时,它会显示“?????”。我应该得到“मनीषा”的结果。我在这里做错了什么。
Select
try { tx = session.beginTransaction();
String hsql = "from Worker";
Query query = session1.createQuery(hsql);
query.list(); // Prints ?????
}
tx.commit();
这是我使用hiberate 4.3.5的db配置文件。我为非英语字符设置了utf-8。如何使用oracle中的hibernate保存和获取hindi数据。
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:xe</property>
<property name="hibernate.connection.password">pass</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="show_sql">false</property>
<property name="hbm2ddl.auto">create</property>
<property name="connection.useUnicode">true</property>
<property name="connection.characterEncoding">utf-8</property>
<property name="connection.charSet">utf-8</property>
<mapping class="com.dep.dao.Worker"></mapping>