vidya archana

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

Recent posts by vidya archana

I've deployed a war file in Jboss. Inside the WEB-INF/lib directory of the application resides the poi zip file. I am able to generate the war using ant and when I try running the application, I am getting "Class Def not found exception".

Is this comming because I'vent placed the zip file inside the server/deploy/lib directory?
17 years ago
Pls find the code below..

I am trying to generate the report from jsp:

<%
response.setContentType("application/vnd.ms-excel.xls");
response.setHeader("content-disposition","attachment;filename=test.xls");
%>

<html>
<head>
<title>Excel</title>
</head>
<body>
<table>
----data comes here
</table>
</body>

When i run this, i am getting a Open/Save dialog box. If i try to save the excel, i am able to vdo that without any problem. And if an excel instance is already opened in my system, and i select open option from the dialog box, again this report is getting opened. But at the same time, if no excel instance is already opened, and i try to open, the excel I am getting an error saying:
"c:\Documents and Settings\199872\Local Settings\Temporary Internet Files\Content.IE5\WV5VMYZ5\test[1].xls could not be found" Please check the file name..etc..

Pls help me in solving this..
[ December 10, 2007: Message edited by: vidya archana ]
17 years ago
JSP
Hi,

I've got an MDB file which containst almost 5 lakhs of records. Please help me to find out a way by which I want to port this data to my oracle database in minimal time programatically.
19 years ago
This is the code I've written.

The objects are : Parent.java


/*
* Created on Aug 29, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package object;

import java.io.Serializable;
import java.util.*;



/**
* @author 128801
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Parent implements Serializable {

private Integer parentId = null;
private String name = null;
private List childList = null;

public Parent() {
//childList = new ArrayList();
}

public void setParentId(Integer i) {
this.parentId = i;
}
public Integer getParentId() {
return this.parentId;
}

public void setName(String name) {
if(name == null) name = "";
this.name = name;
}
public String getName() {
return this.name;
}

public void setChildList(List childList) {
this.childList = childList;
}
public List getChildList() {
return childList;
}
public static void main(String arg[]){

}
}




Child.java

/*
* Created on Aug 29, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package object;

import java.io.Serializable;

import org.apache.struts.action.*;

/**
* @author 128801
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Child implements Serializable {
private Integer childId = null;
private Integer parentId = null;
private String name = null;
private Parent parent = null;


public Child() {

}

public void setChildId(Integer i) {
this.childId = i;
}
public Integer getChildId() {
return this.childId;
}

public void setParentId(Integer i) {
this.parentId = i;
}
public Integer getParentId() {
return this.parentId;
}

public void setName(String name) {
if(name == null) name = "";
this.name = name;
}
public String getName() {
return this.name;
}

public void setParent(Parent parent) {
//System.out.println("comes here =="+parent.getParentId());
this.parent = parent;
//this.parentId = parent.getParentId();
//System.out.println("parent id after setting = "+this.parentId);
}
public Parent getParent() {
return this.parent;
}
}


This is Parent.hbm.xml


-----------------

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping package="object">

<class name="Parent" table="vid_parent">
<id name="parentId" type="integer" column="parent_id">
<generator class="sequence">
<param name="sequence">vid_parent_seq</param>
</generator>
</id>
<list name="childList" outer-join="auto" inverse="true" cascade="save-update">
<key>
<column name="parent_id"/>
</key>
<index column="child_id"/>
<one-to-many class="Child"/>
</list>
<property name="name">
<column name="name" length="100" not-null="false"/>
</property>
</class>
</hibernate-mapping>

---------------------------------------------------------------------------

Child.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping package="object">
<class name="Child" table="vid_child">
<id name="childId" type="integer" column="child_id">
<generator class="sequence">
<param name="sequence">vid_child_seq</param>
</generator>
</id>
<many-to-one name="parentId" class="object.Parent" column="parent_id" />
<property name="name">
<column name="name" length="100" not-null="false"/>
</property>
</class>
</hibernate-mapping>

---------------------------------------------------------------------------

In the handler class I am doing :

List childList = new ArrayList();
childList = emp.getChildList();
for(int i = 0; i<childList.size(); i++) {
Child ch = (Child) childList.get(i);
System.out.println("emp.getId == "+emp.getParentId());
ch.setParent(emp);
}


session.save(emp);

.. the problem is the parent_id value is not getting inserted in the child table. All other values are saved.
Anyone pls help..
Thanks
Vidya
There are two tables parent and child

Table : Parent

Name Null? Type
----------------------------------------- -------- ---------------
ID NOT NULL NUMBER(38)
NAME VARCHAR2(100)

table:child

Name Null? Type
----------------------------------------- -------- --------------
ID NOT NULL NUMBER(38)
PARENT_ID NUMBER(38)
NAME VARCHAR2(100)

this is jst for the starting..
The code i've written is

hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/mytesting</property>
<property name="show_sql">false</property>
<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
<!-- Mapping files -->
<mapping resource="Mapping.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Mapping.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="object.Parent" table="vid_parent">
<id name="id" type="int" unsaved-value="null">
<column name="id" sql-type="int" not-null="true"/>
<generator class="sequence">
<param name="sequence">vid_parent_seq</param>
</generator>
</id>
<property name="name">
<column name="name" length="100" not-null="false"/>
</property>
</class>
<class name="object.Child" table="vid_child">
<id name="id" type="int" unsaved-value="null">
<column name="id" sql-type="int" not-null="true"/>
<generator class="sequence">
<param name="sequence">vid_child_seq</param>
</generator>
</id>
<property name="name">
<column name="name" length="100" not-null="false"/>
</property>
<many-to-one name="parentId" class="object.Parent" column="parent_id"/>
</class>
</hibernate-mapping>


Parent.java

/*
* Created on Aug 29, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package object;

import org.apache.struts.action.*;

/**
* @author 128801
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Parent extends ActionForm {

public int id;
public String name;
public Child child;

public Parent() {
id = 0;
name = "";
}

public void setId(int i) {
this.id = i;
}
public int getId() {
return this.id;
}

public void setName(String name) {
if(name == null) name = "";
this.name = name;
}
public String getName() {
return this.name;
}

public void setChild(Child child) {
this.child = child;
}
public Child getChild() {
return child;
}
public static void main(String arg[]){

}
}


Child.java

/*
* Created on Aug 29, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package object;

import org.apache.struts.action.*;

/**
* @author 128801
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Child extends ActionForm {
private int id;
private int parentId;
private String name;


public Child() {
id = 0;
parentId = 0;
name = "";
}

public void setId(int i) {
this.id = i;
}
public int getId() {
return this.id;
}

public void setParentId(int i) {
this.parentId = i;
}
public int getParentId() {
return this.parentId;
}

public void setName(String name) {
if(name == null) name = "";
this.name = name;
}
public String getName() {
return this.name;
}
}



In createUser fuunciton()


/** adds employe info to table **/
public boolean createUser(Parent emp){
System.out.println("Creating user");
boolean status = false;
try{
this.session =sessions.openSession();
tx = session.beginTransaction();
session.save(emp);
System.out.println("identifier == "+session.getIdentifier(emp));

Child ch = new Child();
ch.setId(1);
ch.setParentId(10);
ch.setName("childname");
session.save(ch);
System.out.println("identifier1 == "+session.getIdentifier(ch));
session.flush();
tx.commit();
session.close();
status = true;
} catch (HibernateException e){
status = false;
System.out.println("eeeeeeee="+ e);
if (tx != null)
try {
tx.rollback();
} catch (HibernateException e1) {
System.out.println("rollback not successful");
}
if (session != null)
try {
session.close();
sessions.close();
} catch (HibernateException e2) {
System.out.println("session close not successful");
}
}
return status;
}


The values are getting stored for Parent. But when I included the code for storing the child values its throwing exception.

Thanks

Vidya
Hi,

I am writing an appln connecting two tables.
This is the exception I am getting. -- "et.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter "

Anyone pls help me to find out why this exception coming?

Thanks

Vidya
In the case of insertion do I need to generate the query, I am using the save() function given by the Session Class. Also the values in the object are coming correctly also.
Hi,
When I try to add a record, this is the exception I am getting.

I am using Hibernate and struts

"net.sf.hibernate.JDBCException: Could not execute JDBC batch update"

Anyone pls help to find out the reason a solution to correct it

Thanks

Vidya
Hi,

I am writting an application using Hibernate and Tomcat5.0 as the app server. When I try to connect to the data base using jndi, I am getting error messgae like this

net.sf.hibernate.HibernateException: Could not find datasource

The same configuration settings work in other machines.(like server.xml, hibernate.cfg.xml and mapping resource xml )

Pls help in solving this issue

Thanks

Vidya
I've written an application which just inserts/updates and deletes from a table.In the db, rt now there are only 2 entries. But in the page 7 rows are displayed, out of which 5 records are added earlier and removed manually from the db. But it is still displaying. How to remove it from the session ?

Thanks

Vidya
Hi,
Why the subprocess represented by the Process object is not getting terminated.
thanks
20 years ago
Hi.

This is a sample code

execStr="mv /tmp/a.txt /root/";

p=r.exec(execStr);
a=p.exitValue();
p.destroy();

while executing this code, i am getting Illegal Thread State Exception : process hasn't exited

Pls help

Thanks
20 years ago
Hello ,
currently i am working with servlets,jsp,javabeans,Now i want to introduce ejb in my projects.Since my problem is that during development is it tedious to deploy the whole application if i change anything .Then how could i test the ejb for the business logic .I know some one working can answer it simply.
so please help by how easily i can develop with ejb.
Hi all....

I want to execute mysql commands using java program.
This is the sample program i wrote.

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.*;

public class ExecLs {

static public void main(String[] args) {
String cmds = "mysql test -u root --password=inapp12 --execute='show tables'";

try {
Process ps = Runtime.getRuntime().exec(cmds);
System.out.print(loadStream(ps.getInputStream()));
System.err.print(loadStream(ps.getErrorStream()));
} catch(IOException ioe) {
ioe.printStackTrace();
}
}

// read an input-stream into a String
static String loadStream(InputStream in) throws IOException {
int ptr = 0;
in = new BufferedInputStream(in);
StringBuffer buffer = new StringBuffer();
while( (ptr = in.read()) != -1 ) {
buffer.append((char)ptr);
}
return buffer.toString();
}

}


But itis not working..
Instead It displays mysql help..
The same command when tried directly works fine

Pls help....
20 years ago