• Post Reply Bookmark Topic Watch Topic
  • New Topic

Inserting data oracle 11g database using myeclipse

 
sivakondalu dokku
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!