• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

hibernate problem

 
Ranch Hand
Posts: 156
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am learning hibernate
I am writting a jsp file.
I am using tomcat, and database as SAP DB


but it is giving this exception.

"net.sf.hibernate.JDBCException: Could not synchronize database state with session: SAP DBTech JDBC: Parameter 2: value too large. exception"


my jsp file is



<%@ page language="java" %>
<%@ page import="category.Cat"%>
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>Lomboz JSP</title>
</head>
<%@ page import="HibernateUtil,java.io.*,java.sql.*,net.sf.hibernate.cfg.Configuration,net.sf.hibernate.SessionFactory,net.sf.hibernate.Session,net.sf.hibernate.Transaction,net.sf.hibernate.MappingException" %>
<body bgcolor="#FFFFFF">

<%
Session sess=null;
try{
Configuration cfg = new Configuration();
cfg.addClass(Cat.class);
SessionFactory sessions = cfg.buildSessionFactory();
sess = sessions.openSession();
Transaction tx = null;
Cat c=new Cat();


tx = sess.beginTransaction();
sess.save(c);
tx.commit();
}
catch (Exception e ) {
out.println(e);
}
finally {
sess.close();
}


%>


</body>
</html>



and my Cat file is

package category;

public class Cat {

private String id;
private String name;

public Cat()
{}

public Cat(String id,String name) {
this.id=id;
this.name=name;
}

public String getId() {
return id;
}

private void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

}


and my Cat.hbm file is


<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="category.Cat" table="cat">
<!-- A 32 hex character is our surrogate key. It's automatically
generated by Hibernate with the UUID pattern. -->
<id name="id" type="string" unsaved-value="null">
<column name="id" sql-type="char(10)" not-null="true"/>
<generator class="uuid.hex"/>
</id>
<!-- A cat has to have a name, but it shouldn' be too long. -->
<property name="name">
<column name="name" length="10" not-null="true"/>
</property>
</class>
</hibernate-mapping>


and my hibernate.cfg is

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/mysap</property>
<property name="show_sql">false</property>
<property name="dialect">net.sf.hibernate.dialect.SAPDBDialect</property>
<!-- Mapping files -->
<mapping resource="Cat.hbm.xml"/>
</session-factory>
</hibernate-configuration>



and my srever.xml contains



<Context path="/quickstart" docBase="quickstart">
<Resource name="jdbc/mysap" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/mysap">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.sap.dbtech.jdbc.DriverSapDB</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:sapdb://192.168.1.174/softlanc</value>
</parameter>
<parameter>
<name>username</name>
<value>DBA</value>
</parameter>
<parameter>
<name>password</name>
<value>dba</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
</ResourceParams>
</Context>



and the data base fields are

cat

id-char(10)
name-char(10)


then what is the problem.plz help me.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic