为什么我在表中插入字符串数据时,怎么会出现以下提示,或者插入的数据显示成乱码,不知道是什么原因请大侠们帮指点一下是什么原因......
[WARN ] 2006-10-13 12:55:08 org.hibernate.util.JDBCExceptionReporter - SQL Error: 1461, SQLState: 72000
[ERROR] 2006-10-13 12:55:08 org.hibernate.util.JDBCExceptionReporter - ORA-01461: can bind a LONG value only for insert into a LONG column
[WARN ] 2006-10-13 12:55:08 org.hibernate.util.JDBCExceptionReporter - SQL Error: 1461, SQLState: 72000
[ERROR] 2006-10-13 12:55:08 org.hibernate.util.JDBCExceptionReporter - ORA-01461: can bind a LONG value only for insert into a LONG column
[ERROR] 2006-10-13 12:55:08 org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at filters.HibernateFilter.doFilter(HibernateFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:41)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tom
10 个解决方案
#1
你的字段类型是LONG,当然不能插入字符了。
#2
我没有设成long型啊,数据类型就是string型啊
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.webrage.domain">
<class name="S20" table="S20">
<id
column="S2000"
name="S2000"
type="integer"
>
<!--<generator class="native" /><generator class="identity"/>-->
<generator class="sequence" >
<param name="sequence">SQ_S20</param>
</generator>
</id>
<property
column="S2002"
length="100"
name="S2002"
not-null="false"
type="string"
/>
<property
column="S2006"
length="10"
name="S2006"
not-null="false"
type="integer"
/>
<property
column="S2003"
length="50"
name="S2003"
not-null="false"
type="string"
/>
<property
column="S2001"
length="50"
name="S2001"
not-null="false"
type="string"
/>
<property
column="S2008"
length="10"
name="S2008"
not-null="false"
type="integer"
/>
<property
column="S2004"
length="10"
name="S2004"
not-null="false"
type="integer"
/>
<property
column="S2005"
length="10"
name="S2005"
not-null="false"
type="integer"
/>
<property
column="S2007"
length="10"
name="S2007"
not-null="false"
type="integer"
/>
<property
column="S2005"
length="10"
name="ParentId"
not-null="false"
type="integer"
insert ="false"
update ="false"
/>
<set
name="Children"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
order-by ="S2006 ASC"
>
<key
column="S2005"
/>
<one-to-many
class="com.webrage.domain.S20"
/>
</set>
<set
name="S01Set"
table ="S22"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
>
<key
column="S2000"
/>
<many-to-many
class="com.webrage.domain.S01"
column="S0100"
outer-join="auto"
/>
</set>
<set
name="S02Set"
table ="S23"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
>
<key
column="S2000"
/>
<many-to-many
class="com.webrage.domain.S02"
column="S0200"
outer-join="auto"
/>
</set>
<set
name="S04Set"
table ="S24"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
>
<key
column="S2000"
/>
<many-to-many
class="com.webrage.domain.S04"
column="S0400"
outer-join="auto"
/>
</set>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.webrage.domain">
<class name="S20" table="S20">
<id
column="S2000"
name="S2000"
type="integer"
>
<!--<generator class="native" /><generator class="identity"/>-->
<generator class="sequence" >
<param name="sequence">SQ_S20</param>
</generator>
</id>
<property
column="S2002"
length="100"
name="S2002"
not-null="false"
type="string"
/>
<property
column="S2006"
length="10"
name="S2006"
not-null="false"
type="integer"
/>
<property
column="S2003"
length="50"
name="S2003"
not-null="false"
type="string"
/>
<property
column="S2001"
length="50"
name="S2001"
not-null="false"
type="string"
/>
<property
column="S2008"
length="10"
name="S2008"
not-null="false"
type="integer"
/>
<property
column="S2004"
length="10"
name="S2004"
not-null="false"
type="integer"
/>
<property
column="S2005"
length="10"
name="S2005"
not-null="false"
type="integer"
/>
<property
column="S2007"
length="10"
name="S2007"
not-null="false"
type="integer"
/>
<property
column="S2005"
length="10"
name="ParentId"
not-null="false"
type="integer"
insert ="false"
update ="false"
/>
<set
name="Children"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
order-by ="S2006 ASC"
>
<key
column="S2005"
/>
<one-to-many
class="com.webrage.domain.S20"
/>
</set>
<set
name="S01Set"
table ="S22"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
>
<key
column="S2000"
/>
<many-to-many
class="com.webrage.domain.S01"
column="S0100"
outer-join="auto"
/>
</set>
<set
name="S02Set"
table ="S23"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
>
<key
column="S2000"
/>
<many-to-many
class="com.webrage.domain.S02"
column="S0200"
outer-join="auto"
/>
</set>
<set
name="S04Set"
table ="S24"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
>
<key
column="S2000"
/>
<many-to-many
class="com.webrage.domain.S04"
column="S0400"
outer-join="auto"
/>
</set>
</class>
</hibernate-mapping>
#3
我hibernate不熟 你往long字段插入字符是不行的
sql="insert into msg_info values (?,?,?,?[long类型字段],'C',sysdate,sysdate+"+msgterm+",?)";
pstat1 = conn.prepareStatement(sql);
pstat1.setLong(1, msg_id);
pstat1.setInt(2, msg_gp_id);
pstat1.setString(3, msg_title);
pstat1.setCharacterStream(4,new StringReader(msg_info.toString()),msg_info.length());
conn.commit();
pstat1.setLong(5, this.upid);
sql="insert into msg_info values (?,?,?,?[long类型字段],'C',sysdate,sysdate+"+msgterm+",?)";
pstat1 = conn.prepareStatement(sql);
pstat1.setLong(1, msg_id);
pstat1.setInt(2, msg_gp_id);
pstat1.setString(3, msg_title);
pstat1.setCharacterStream(4,new StringReader(msg_info.toString()),msg_info.length());
conn.commit();
pstat1.setLong(5, this.upid);
#4
不会吧,我没有设到字段有 long 型的啊,怎么会那种提示郁闷啊........
#5
说的是你的数据库定义类型是LONG,跟hibernate没关系。
#6
是不是bind的表和列不对?
仔细检查一下.
仔细检查一下.
#7
数据库里面设的不是字符型吧?
#8
数据库定义类型是LONG 也不可能,但是我有时候插入数据又是乱码..郁闷....ing
我检查了也没有这种可能......
我检查了也没有这种可能......
#9
改为varchar
看看
看看
#10
驱动的问题,解决了
#1
你的字段类型是LONG,当然不能插入字符了。
#2
我没有设成long型啊,数据类型就是string型啊
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.webrage.domain">
<class name="S20" table="S20">
<id
column="S2000"
name="S2000"
type="integer"
>
<!--<generator class="native" /><generator class="identity"/>-->
<generator class="sequence" >
<param name="sequence">SQ_S20</param>
</generator>
</id>
<property
column="S2002"
length="100"
name="S2002"
not-null="false"
type="string"
/>
<property
column="S2006"
length="10"
name="S2006"
not-null="false"
type="integer"
/>
<property
column="S2003"
length="50"
name="S2003"
not-null="false"
type="string"
/>
<property
column="S2001"
length="50"
name="S2001"
not-null="false"
type="string"
/>
<property
column="S2008"
length="10"
name="S2008"
not-null="false"
type="integer"
/>
<property
column="S2004"
length="10"
name="S2004"
not-null="false"
type="integer"
/>
<property
column="S2005"
length="10"
name="S2005"
not-null="false"
type="integer"
/>
<property
column="S2007"
length="10"
name="S2007"
not-null="false"
type="integer"
/>
<property
column="S2005"
length="10"
name="ParentId"
not-null="false"
type="integer"
insert ="false"
update ="false"
/>
<set
name="Children"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
order-by ="S2006 ASC"
>
<key
column="S2005"
/>
<one-to-many
class="com.webrage.domain.S20"
/>
</set>
<set
name="S01Set"
table ="S22"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
>
<key
column="S2000"
/>
<many-to-many
class="com.webrage.domain.S01"
column="S0100"
outer-join="auto"
/>
</set>
<set
name="S02Set"
table ="S23"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
>
<key
column="S2000"
/>
<many-to-many
class="com.webrage.domain.S02"
column="S0200"
outer-join="auto"
/>
</set>
<set
name="S04Set"
table ="S24"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
>
<key
column="S2000"
/>
<many-to-many
class="com.webrage.domain.S04"
column="S0400"
outer-join="auto"
/>
</set>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.webrage.domain">
<class name="S20" table="S20">
<id
column="S2000"
name="S2000"
type="integer"
>
<!--<generator class="native" /><generator class="identity"/>-->
<generator class="sequence" >
<param name="sequence">SQ_S20</param>
</generator>
</id>
<property
column="S2002"
length="100"
name="S2002"
not-null="false"
type="string"
/>
<property
column="S2006"
length="10"
name="S2006"
not-null="false"
type="integer"
/>
<property
column="S2003"
length="50"
name="S2003"
not-null="false"
type="string"
/>
<property
column="S2001"
length="50"
name="S2001"
not-null="false"
type="string"
/>
<property
column="S2008"
length="10"
name="S2008"
not-null="false"
type="integer"
/>
<property
column="S2004"
length="10"
name="S2004"
not-null="false"
type="integer"
/>
<property
column="S2005"
length="10"
name="S2005"
not-null="false"
type="integer"
/>
<property
column="S2007"
length="10"
name="S2007"
not-null="false"
type="integer"
/>
<property
column="S2005"
length="10"
name="ParentId"
not-null="false"
type="integer"
insert ="false"
update ="false"
/>
<set
name="Children"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
order-by ="S2006 ASC"
>
<key
column="S2005"
/>
<one-to-many
class="com.webrage.domain.S20"
/>
</set>
<set
name="S01Set"
table ="S22"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
>
<key
column="S2000"
/>
<many-to-many
class="com.webrage.domain.S01"
column="S0100"
outer-join="auto"
/>
</set>
<set
name="S02Set"
table ="S23"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
>
<key
column="S2000"
/>
<many-to-many
class="com.webrage.domain.S02"
column="S0200"
outer-join="auto"
/>
</set>
<set
name="S04Set"
table ="S24"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
>
<key
column="S2000"
/>
<many-to-many
class="com.webrage.domain.S04"
column="S0400"
outer-join="auto"
/>
</set>
</class>
</hibernate-mapping>
#3
我hibernate不熟 你往long字段插入字符是不行的
sql="insert into msg_info values (?,?,?,?[long类型字段],'C',sysdate,sysdate+"+msgterm+",?)";
pstat1 = conn.prepareStatement(sql);
pstat1.setLong(1, msg_id);
pstat1.setInt(2, msg_gp_id);
pstat1.setString(3, msg_title);
pstat1.setCharacterStream(4,new StringReader(msg_info.toString()),msg_info.length());
conn.commit();
pstat1.setLong(5, this.upid);
sql="insert into msg_info values (?,?,?,?[long类型字段],'C',sysdate,sysdate+"+msgterm+",?)";
pstat1 = conn.prepareStatement(sql);
pstat1.setLong(1, msg_id);
pstat1.setInt(2, msg_gp_id);
pstat1.setString(3, msg_title);
pstat1.setCharacterStream(4,new StringReader(msg_info.toString()),msg_info.length());
conn.commit();
pstat1.setLong(5, this.upid);
#4
不会吧,我没有设到字段有 long 型的啊,怎么会那种提示郁闷啊........
#5
说的是你的数据库定义类型是LONG,跟hibernate没关系。
#6
是不是bind的表和列不对?
仔细检查一下.
仔细检查一下.
#7
数据库里面设的不是字符型吧?
#8
数据库定义类型是LONG 也不可能,但是我有时候插入数据又是乱码..郁闷....ing
我检查了也没有这种可能......
我检查了也没有这种可能......
#9
改为varchar
看看
看看
#10
驱动的问题,解决了