Cherry Gupta

Greenhorn
+ Follow
since Feb 09, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Cherry Gupta

Hi,

I have checked the jars and they are of same version only.

the result of the below statement is javax.naming.Reference:
System.out.println(obj.getClass().getName());

means its returning javax.naming.Reference

but then how I convert javax.naming.Reference to javax.sql.DataSource?
12 years ago
Thanks Peter for replying.

Now NameNotFoundException has gone.

But now I m getting different exception:

java.lang.ClassCastException: javax.naming.Reference cannot be cast to javax.sql.DataSource
at test.DatasourceTest.lookup(Datasource_demo.java:46)
at test.Datasource_demo.main(Datasource_demo.java:80)

I m getting this error when I m trying to convert from Object to DataSource class at below line.
DataSource o=(DataSource)ctx.lookup(name);

Please help!!!


Regards,
Cherry
12 years ago
Hi,

I m trying to connect to datasource from my standalone program to JBOSS. But I m getting the below error:

javax.naming.NameNotFoundException: commsDSLocal not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
at org.jnp.server.NamingServer.lookup(NamingServer.java:443)

my standalone program is:



I have configured commDSLocal in -ds.xml file in JBOSS and started the JBOSS server but still I m getting this issue.

Please help to resolve the issue.

Thanks in advance!!!

Regards,
Cherry
12 years ago
Hi,

Can anyone tell whats the use of User Defined Exceptions?

What will happen if we make a user defined exception by extending IOException rather that Exception class?
12 years ago
Hi, I m new to hibernate.

I have written a Hibernate test program on the parent / child relationship but I m getting below exception:

Caused by: java.sql.BatchUpdateException: ORA-02291: integrity constraint (ATSUSER.BOOK_R01) violated - parent key not found

The idea is an author can have many books:

Below are the details:

Test Program
public class Book_test
{
public static void main(String[] args)
{
Session session = HibernateUtil.getSession();
Transaction tx = session.beginTransaction();
Author author = new Author();
Book book = new Book();
book.setBookName("Kane and Abel");
Set<Book> bookSet = new HashSet<Book>();
author.addBook(book);
session.saveOrUpdate(author);
tx.commit();
session.close();
}
}

Author.java:
public class Author
{
private String authorName;
private int authorId;
private String bookName;
private Set<Book> authorBooks=new HashSet<Book>();

public Author(){}

public Author(String authorName, Set<Book> authorBooks)
{
this.authorName=authorName;
this.authorBooks=authorBooks;
}

public Author(int authorId, String authorName, Set<Book> authorBooks)
{
this.authorId=authorId;
this.authorName=authorName;
this.authorBooks=authorBooks;
}

public String getAuthorName() {
return authorName;
}
public void setAuthorName(String authorName) {
this.authorName = authorName;
}
public int getAuthorId() {
return authorId;
}
public void setAuthorId(int authorId) {
this.authorId = authorId;
}

public Set<Book> getAuthorBooks() {
return authorBooks;
}
public void setAuthorBooks(Set<Book> authorBooks) {
this.authorBooks = authorBooks;
}

public String getBookName() {
return bookName;
}

public void setBookName(String bookName) {
this.bookName = bookName;
}

public void addBook(Book book)
{
if(book==null)
{
setAuthorBooks(new HashSet<Book>());
}
getAuthorBooks().add(book);
}

}

Book.java:
package hibernate;

public class Book
{
private int Id;
private String bookName;
private int authorId;

public Book(){}

public Book(int id, String bookName)
{
this.Id=id;
this.bookName=bookName;
}

public int getId() {
return Id;
}
public void setId(int id) {
Id = id;
}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}

public int getAuthorId() {
return authorId;
}

public void setAuthorId(int authorId) {
this.authorId = authorId;
}
}

Author.hbm.xml:

<hibernate-mapping>

<class name="hibernate.Author" table="author">
<id name="authorId" column="author_id">
<generator class="increment"/>
</id>

<property name="authorName" column="author_name"/>
<property name="bookName" column="book_name"/>
<set name="authorBooks" table="book" cascade="all">
<key column="author_id" />
<one-to-many class="hibernate.Book" />
</set>
</class>

</hibernate-mapping>

Database tables:

table AUTHOR:
AUTHOR_ID NUMBER, Primary key
BOOK_NAME VARCHAR2(40 BYTE),
AUTHOR_NAME VARCHAR2(30 BYTE)

table BOOK:
ID NUMBER(19) NOT NULL,
BOOKNAME VARCHAR2(255 BYTE),
AUTHOR_ID NUMBER NOT NULL FOREIGN KEY (AUTHOR_ID)
REFERENCES AUTHOR (AUTHOR_ID));

Please help to solve the problem.

Thnaks in advance!!!

Regards,
Chandni
Hi,

I m new to hibernate.
I m trying to integrate hibernate with servlet using Tomcat but I m getting the exception org.hibernate.HibernateException: /hibernate.cfg.xml not found

Please tell me where to put "hibernate.cfg.xml" in my project. I m using eclipse.

Thanks
Cherry
still the same problem.

I had put the jar file in lib folder to but no luck.
I have put the jar file like this

Do I need to place the jar file somewhere else also?
I have put the jar file in libraries folder from where all other jar files are executed at runtime but still saying ClassNotFoundException.

Please help me out.

Thanks
Cherry
Hi,

When I m trying to run my servlet from eclipse using JDBC coding I m getting ClassNotFoundException on line Class.forName("com.mysql.jdbc.Driver")

I have already placed mysql executable jar file into the build path of the project but still no luck.m I need to do anything else to make this class available?

Please help me to sort out the problem!

Thanks
Cherry
thanks Sagar for quick response

but stil I m not able to get that how I set a string in servlet and get that in jsp if jsp is on another server?

please provide me some kind of code for it.

Thanks
Cherry
14 years ago
How do you pass a string from servlet to jsp if jsp is on another server?

Please provide me solution for this.

Thanks
Cherry
14 years ago
I have already unzip the jboss and when I click browse I m getting the path till bin but not to run.jar
'F:\jboss-5.1.0.GA-jdk6\jboss-5.1.0.GA\bin'.
though bin consist of run.jar
but it is not displaying in eclipse
14 years ago
I have downloaded the jboss from jboss site but I dont know how to install it or run it on my machine.
how I run it on my machine?

Thanks
Cherry
14 years ago
sorry its not 0.5 its v5.0

when I try doing this
windows->preferences->server->runtime enviroment->add->Jboss->Jboss v5.0

I m getting the error mentioned above

I m using eclipse version 'eclipse-jee-galileo-SR1-win32'
and JBoss Version 'jboss-5.1.0.GA-jdk6'

please help me to solve the problem.

Thanks
Cherry
14 years ago