subhashchandra medhiassam

Ranch Hand
+ Follow
since Sep 10, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by subhashchandra medhiassam



The above is the code for a client program which uses Sun RPC. When i try to execute this program, i am getting portmap failure ? Could anybody tell me why this is happening and what could be the remedy for this ?

Subhash
15 years ago
Dear friends,
I would like to know whether ONC RPC is the same as the original version of SUN RPC. If not then from where could i get the stack of the original version of SUN RPC ?

Thanks,
Subhash
15 years ago
Thanks. But i would like to know how to execute the query and retrieve the result of the avg(...) function. Kindly help.

Subhash
Dear friends,
I would like to know how to use the avg(...) aggregate function available in hibernate. Kindly help me with some simple example.

Thanks in advance,
Subhash
Hi,
I have sorted out the problem. I had not included some of the jars. Thanks for the help anyway.

Subhash
Dear friends,
I have run into a problem and need your help in solving it.

I am trying to map the values of the fields of an object into a relational database table.

The file hibernate.cfg.xml looks like the following :



The POJO class named ContactDetails.java looks like the following :




And the class used to set the values into the POJO is named as FirstExample.java. It looks like the following:


But when i execute FirstExample.java, i am getting a NulPointerException corresponding to the statement session.flush(); which is in the finally block.
What should i do now ? Kindly help me out.


Subhash
Hi all,
I would like to create two tables,say A1 and B2, such that there is a one-to-many association from A to B. How should i proceed? I would like to use JDBC.

Kindly help.

Thanks,
Subhash
Okay, thanks Bittoo. I changed 5 to 1 and it's working now.
Dear friends,
I am using JDBC to create two tables in MYSQL and then insert data into these two tables. The tables are named as Publisher and Book. For each row in table Publisher there could be multiple rows in table Book.

The code looks like the folowing:

PreparedStatement pstmt1 = null;
PreparedStatement pstmt2 = null;
PreparedStatement pstmt3 = null;
PreparedStatement pstmt4 = null;

try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}catch(Exception e){
System.out.println(e.getMessage());
}
try{
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/hibernatetutorial?" +
"user=root&password=root");

pstmt1 = conn.prepareStatement("CREATE Table Publisher(ID bigint(20) primary key,CODE varchar(4),PUBLISHER_NAME varchar(100),ADDRESS varchar(200))");
boolean check1 = pstmt1.execute();

pstmt2 = conn.prepareStatement("CREATE Table Book(ID bigint(20),ISBN varchar(50),BOOK_NAME varchar(100),PUBLISH_DATE date,PRICE int(11),PUBLISHER_ID bigint(20),foreign key(PUBLISHER_ID) REFERENCES Publisher(ID))");
boolean check2 = pstmt2.execute();

pstmt3 = conn.prepareStatement("INSERT INTO Publisher values(?,?,?,?)");
pstmt3.setLong(1,(long)1);
pstmt3.setString(2,"adfs");
pstmt3.setString(3,"zfkljfj dalldl");
pstmt3.setString(4,"100 skhdkhke,sojol,lskjs");
boolean check3 = pstmt3.execute();

pstmt4 = conn.prepareStatement("INSERT INTO Book values(?,?,?,?,?,?)");

Date date = Date.valueOf("03-10-2008");
pstmt4.setLong(1,(long)1);
pstmt4.setString(2,"abcdef");
pstmt4.setString(3,"xyz");
pstmt4.setDate(4,date);
pstmt4.setInt(5,100);
pstmt4.setLong(6,(long)5);
boolean check4 = pstmt4.execute();


When i execute this program,however, i am getting the following message:

Duplicate key or integrity constraint violation message from server: "Cannot add or update a child row: a foreign key constraint fails (`hibernatetutorial/book`, CONSTRAINT `book_ibfk_1` FOREIGN KEY (`PUBLISHER_ID`) REFERENCES `publisher` (`ID`))"

What could have gone wrong ? Kindly help.

Thanks,
Subhash
Hi,
when i changed the program to print the stacktrace it printed the following message:



I got it. thanks.
[ September 29, 2008: Message edited by: subhashchandra medhiassam ]
i have used various types like mediumint and bigint for the column ID of table Contact. But nothing works.
There's nothing more in the message.

what should be the type of column id of Contact table? Kindly help.

Thanks,
Subhash
Hi,
Could anybody kindly help me out. Please kindly help me out. It's urgent.

Thanks,
Subhash
[ September 29, 2008: Message edited by: subhashchandra medhiassam ]
Hi all,
I have a table named Contact in MYSQL. This table looks like the following:

Column Type
------------- -------------
ID decimal
FIRSTNAME varchar
LASTNAME varchar
EMAIL varchar

There is only a single row of data in the table.

This row contains the following data:

ID = 6,FIRSTNAME=Subhash,LASTNAME=Medhi,[email protected]

Corresponding to this table i have a class Contact.java. It looks like the following:



My hbm.xml file looks like this:



I have a third class in which i am trying to update table Contact. This class named as UpdateExample.java looks like the following:



When i run this class, however, i am getting the following message:



The table is not getting updated.

Could anybody kindly tell me what exactly could the problem be?

Thanks,
Subhash
That line corresponds to "session.flush();". Anyway, the problem is solved now. Thanks, for your response, Paul.