wood burning stoves 2.0*
The moose likes JDBC and the fly likes Inserting data oracle 11g database using myeclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Inserting data oracle 11g database using myeclipse" Watch "Inserting data oracle 11g database using myeclipse" New topic
Author

Inserting data oracle 11g database using myeclipse

sivakondalu dokku
Greenhorn

Joined: Jan 17, 2012
Posts: 5
Welcome to coderanch

I have problem in orm module .that is i want to insert data into oracle database. the following is the code while executing the code orm sending query but it not update in database..


package info.inetsolv;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.orm.hibernate3.HibernateTemplate;

public class InsertRecord {


public static void main(String[] args) {
ApplicationContext container = new ClassPathXmlApplicationContext("applicationContext.xml");
HibernateTemplate ht = (HibernateTemplate)container.getBean("ht");

Product p = new Product();

p.setPid(10);
p.setName("ten");
p.setPrice(1.0);

ht.save(p);


}

}




this is my configuration file in spring


<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">


<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbcracle:thin:@localhost:1521:xe">
</property>
<property name="username" value="spring"></property>
<property name="password" value="spring"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="file:src/hibernate.cfg.xml">
</property>
</bean>
<bean id="ht"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>

Thanks and Regards
sivakondalu
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Hi sivakondalu,

It would help more if you added a exception or error detail in your post? OR what tutorial you're following for this ?

I am not good in spring but I having doubt in your session factory initializing in spring configuration check this SessionFactory setup in a Spring container. which has clearly state data source property under session factory bean.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
 
jQuery in Action, 2nd edition
 
subject: Inserting data oracle 11g database using myeclipse
 
Similar Threads
commit data in hibernate template through spring
I am getting org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity:
Spring,JUnit, Hibernate and persistence db but not insert
HibernateTemplate object is null
Trouble converting a Spring JDBC app to use Spring Hibernate