-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Datasource is not bound
PostPosted: Thu Aug 11, 2005 7:51 am 
Newbie

Joined: Tue Aug 09, 2005 1:42 am
Posts: 8
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: hibernate3.0

Mapping documents:
<?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>

<class name="newtry_test" table="newtry_test">


<id name="uname" unsaved-value="null" >
<column name="uname" sql-type="varchar(20)" not-null="true"/>
<generator class="assigned">

</generator>
</id>
<!--property name="userName"/-->


</class>

</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
try
{

//str=str+"Hello From StateLess Session Bean";
System.out.println(str);

Configuration cfg = new Configuration();
/*.addClass(newtry_test.class)
.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLServerDialect")
.setProperty("hibernate.connection.driver_class", "com.microsoft.jdbc.sqlserver.SQLServerDriver")
.setProperty("hibernate.connection.url", "jdbc:microsoft:sqlserver://192.168.16.5:1433")
.setProperty("hibernate.connection.username", "sa")
.setProperty("hibernate.connection.password", "sa")
.setProperty("hibernate.hbm2ddl.auto", "update")
.setProperty("hibernate.show_sql", "true");*/
cfg.configure(new File(System.getProperties().getProperty("sun.boot.library.path")+"\\hibernate.cfg.xml")).buildSessionFactory();
//.buildSessionFactory();
//cfg.configure(new File("D:\\newtry\\jar\\hibernate.cfg.xml"));
System.out.println("hjhk");

Context ctx = new InitialContext();
SessionFactory sessionFactory = (SessionFactory) ctx.lookup("java:/MSSQLDS");
Session session = sessionFactory.openSession();


//System.out.println("null sessionfactory");

//SessionFactory sessionFactory = cfg.buildSessionFactory();
System.out.println("bnmbnmbm");

//Configuration config = new Configuration().addResource("d:\\newtry\\jar\\newtry_test.hbm.xml")
/*Configuration config = new Configuration().addClass(d:\\newtry\\jar\\newtry_test.class)
.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLServerDialect")
.setProperty("hibernate.connection.driver_class", " com.microsoft.jdbc.sqlserver.SQLServerDriver")
.setProperty("hibernate.connection.url", "jdbc:microsoft:sqlserver://localhost:1433/msdb");
SessionFactory session = config.buildSessionFactory();*/


newtry_test test=new newtry_test(str);
//Context ctx=new InitialContext();

//Session session;
///Session session = (sessionFactory)ctx.lookup("java:/MSSQLDS");
//Session session = cfg.openSession();
Transaction tx = session.beginTransaction();
session.save(test);
System.out.println("After session.save");
tx.commit();
System.out.println("After transaction commit");
session.flush();
System.out.println("After flush");
session.close();

//str=str+"Hello From StateLess Session Bean";
return "DATA SAVED SUCESSFULLY";

}catch(Exception e)
{
System.out.println(e);
return e.toString();
//return "From StatelesBean Interface";
}

}

}
Full stack trace of any exception that occurs:
No exception is occurd.Table generation done by hibernate.But,no data is entering in table.Query is not performed.It 's find like an infinite loop.
Can u give code or any link from I can understand how can I solve this problem.

When I am not using datasource it's work fine.
Name and version of the database you are using:
MS SQL Server 2000
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:
log 4j


Top
 Profile  
 
 Post subject: Re: Datasource is not bound
PostPosted: Thu Aug 11, 2005 8:58 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
mkundu wrote:
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: hibernate3.0

Mapping documents:
<?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>

<class name="newtry_test" table="newtry_test">


<id name="uname" unsaved-value="null" >
<column name="uname" sql-type="varchar(20)" not-null="true"/>
<generator class="assigned">

</generator>
</id>
<!--property name="userName"/-->


</class>

</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
try
{

//str=str+"Hello From StateLess Session Bean";
System.out.println(str);

Configuration cfg = new Configuration();
/*.addClass(newtry_test.class)
.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLServerDialect")
.setProperty("hibernate.connection.driver_class", "com.microsoft.jdbc.sqlserver.SQLServerDriver")
.setProperty("hibernate.connection.url", "jdbc:microsoft:sqlserver://192.168.16.5:1433")
.setProperty("hibernate.connection.username", "sa")
.setProperty("hibernate.connection.password", "sa")
.setProperty("hibernate.hbm2ddl.auto", "update")
.setProperty("hibernate.show_sql", "true");*/
cfg.configure(new File(System.getProperties().getProperty("sun.boot.library.path")+"\\hibernate.cfg.xml")).buildSessionFactory();
//.buildSessionFactory();
//cfg.configure(new File("D:\\newtry\\jar\\hibernate.cfg.xml"));
System.out.println("hjhk");

Context ctx = new InitialContext();
SessionFactory sessionFactory = (SessionFactory) ctx.lookup("java:/MSSQLDS");
Session session = sessionFactory.openSession();


//System.out.println("null sessionfactory");

//SessionFactory sessionFactory = cfg.buildSessionFactory();
System.out.println("bnmbnmbm");

//Configuration config = new Configuration().addResource("d:\\newtry\\jar\\newtry_test.hbm.xml")
/*Configuration config = new Configuration().addClass(d:\\newtry\\jar\\newtry_test.class)
.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLServerDialect")
.setProperty("hibernate.connection.driver_class", " com.microsoft.jdbc.sqlserver.SQLServerDriver")
.setProperty("hibernate.connection.url", "jdbc:microsoft:sqlserver://localhost:1433/msdb");
SessionFactory session = config.buildSessionFactory();*/


newtry_test test=new newtry_test(str);
//Context ctx=new InitialContext();

//Session session;
///Session session = (sessionFactory)ctx.lookup("java:/MSSQLDS");
//Session session = cfg.openSession();
Transaction tx = session.beginTransaction();
session.save(test);
System.out.println("After session.save");
tx.commit();
System.out.println("After transaction commit");
session.flush();
System.out.println("After flush");
session.close();

//str=str+"Hello From StateLess Session Bean";
return "DATA SAVED SUCESSFULLY";

}catch(Exception e)
{
System.out.println(e);
return e.toString();
//return "From StatelesBean Interface";
}

}

}
Full stack trace of any exception that occurs:
No exception is occurd.Table generation done by hibernate.But,no data is entering in table.Query is not performed.It 's find like an infinite loop.
Can u give code or any link from I can understand how can I solve this problem.

When I am not using datasource it's work fine.
Name and version of the database you are using:
MS SQL Server 2000
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:
log 4j


Can you repost this code after removing all of the lines that are commented out and also use the <code> tags around the code to preserve the formatting.

Thx

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 1:30 am 
Newbie

Joined: Tue Aug 09, 2005 1:42 am
Posts: 8
Here is my Code::::::
<code>
try
{

Configuration cfg = new Configuration();
cfg.configure(new File(System.getProperties().getProperty("sun.boot.library.path")+"\\hibernate.cfg.xml")).buildSessionFactory();

Context ctx = new InitialContext();
SessionFactory sessionFactory = (SessionFactory) ctx.lookup("java:/MSSQLDS");
Session session = sessionFactory.openSession();
newtry_test test=new newtry_test(str);

Transaction tx = session.beginTransaction();
session.save(test);
tx.commit();
session.flush();
session.close();

return "DATA SAVED SUCESSFULLY";

}catch(Exception e)
{
System.out.println(e);
return e.toString();

}

</code>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 2:41 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
Your code tag is not the right one.

Why do you say it is like an infinite loop ? Does your app terminate ? If not where does it hang ?
If your app terminate, did you activate the sql trace to see that nothing happen ?
If it so, try to activate all hibernate debug log and post it

_________________
Seb
(Please don't forget to give credits if you found this answer useful :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.