Janarthan Sathiamurthy

Greenhorn
+ Follow
since Jan 08, 2003
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 Janarthan Sathiamurthy

Hi,
By never finish loading means, "the browsers status bar should display opening page ...".
Also i do not want to commit the response. i want to keep on writing in to it till the time i prefer.
Is this possible with java. A friend of mine has implementerd tthis in php. I want this in java..
Please help...
Janarthan S
18 years ago
Hi,
I want my servlet to output a page that will 'never finish loading' in the browser(I.E). After an interval of 3 secs, i want to write some information on the output page without reloading the page.
Please Help....
Thanks in advance....
Janarthan S
[ March 30, 2003: Message edited by: Janarthan Sathiamurthy ]
18 years ago
>>Hi,
>>
>>I am using 1.4.1_01 of the jre plugin.
>>I have a swing applet.
>>In the JApplet i have a JscrollPane.
>>I am placing JTree on this JscrollPane.
>>I am using the default lookandfeel of java.
>>Now I am using tree.putClientProperty("JTree.lineStyle", "Angled");
>>But i did not get expected lines detailing the relationships between nodes.
>>
>>I tried the same by setting the UIManager to Windows look and feel. But the result was same.
>
>How can I get vertical line
>>Please Help.
18 years ago
Hi folks,
We have to call a C++ code from a session bean.
We had to go for JNI.
My doubt is, Is there any chance that this bridge can fail? Are EJB containers failsafe in this regard.
The doubt whether EJB should be used when calling C/C++ code always lingers.
Please help.
Regards,
Janarthan S
I am using jboss.
I am using xdoclet to autogenerate the reqd intefaces.
My Entity bean reads as -
package helloworld;
/**
* @ejb.bean type="BMP"
* name="helloworld/BMPBean"
* jndi-name="helloworld/BMP"
* view-type="both"
* @ejb.pk generate = "true" class = "helloworld.BMPPK"
* @ejb:transaction type="Required"
* @jboss:table-name table-name="catagory"
* @jboss:create-table create="false"
* @jboss:remove-table create="false"
*/
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import javax.ejb.RemoveException;
import javax.ejb.CreateException;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
public abstract class BMPBean implements EntityBean {
int catagoryId;
String name;
int parentId;
// Business methods
/**
* @ejb.persistent-field
* @ejb.interface-method
* @jboss:column-name CATAGORY_ID
* @ejb.interface-method view-type="both"
*/
public int getCatagoryId() {
return catagoryId;
}
/**
* @ejb.interface-method view-type="both"
*/
public void setCatagoryId(int vCatagoryId) {
catagoryId = vCatagoryId;
}
/**
* @ejb.persistent-field
* @ejb.interface-method
* @jboss:column-name NAME
* @ejb.interface-method view-type="both"
*/
public String getName() {
return name;
}
/**
* @ejb.interface-method view-type="both"
*/
public void setName(String vName) {
name = vName;
}
/**
* @ejb.persistent-field
* @ejb.interface-method
* @jboss:column-name PARENT_ID
* @ejb.interface-method view-type="both"
*/
public int getParentId() {
return parentId;
}
/**
* @ejb.interface-method view-type="both"
*/
public void setParentId(int vParentId) {
parentId = vParentId;
}
// Callback methods
/**
* Create Catagory.
*
* @ejb.create-method
*/
public void ejbCreate(int vCatagoryId, String vName, int vParentId) throws CreateException {
// Logic to insert value in to the database
Connection mConn = null;
try {
mConn = getConnection();
String mInsertSql = "INSERT INTO CATAGORY(CATAGORY_ID, NAME, PARENT_ID) VALUES(" + vCatagoryId + ", '" + vName + "', " + vParentId + ")";
Statement mStatement = mConn.createStatement();
mStatement.executeUpdate(mInsertSql);
}
catch (Exception vException){
System.out.println("Exception in ejbCreate()" + vException);
}
finally {
if (mConn != null){
try {
mConn.close();
}
catch (SQLException vSQLException){
System.out.println("Closing Conn exception " + vSQLException);
}
}
}
}
public void ejbPostCreate(int vCatagoryId, String vName, int vParentId) {
}
public void ejbRemove() throws RemoveException {
// Logic to delete the inserted record
System.out.println("Write Logic to delete the inserted record");
}
public int ejbFindByPrimaryKey(int vCatagoryId) {
Connection mConn = null;
try {
mConn = getConnection();
Statement mStatement = mConn.createStatement();
String mSql = "SELECT * FROM CATAGORY WHERE CATAGORY_ID=" + vCatagoryId;
ResultSet mResultSet = mStatement.executeQuery(mSql);
if (mResultSet.next()) {
System.out.println("In ejbFindByPrimaryKey() method");
System.out.println("Catagory Id is " + mResultSet.getString("CATAGORY_ID"));
System.out.println("Name is " + mResultSet.getString("NAME"));
System.out.println("Parent ID is " + mResultSet.getString("PARENT_ID"));
}
mResultSet = null;
return vCatagoryId; // FIX ME
}
catch (Exception vException) {
System.out.println("Exception in ejbFindByPrimaryKey()" + vException);
}
finally {
if (mConn != null){
try {
mConn.close();
}
catch (SQLException vSQLException){
System.out.println("Closing Conn exception " + vSQLException);
}
}
}
return 0;
}
public void ejbLoad() {
System.out.println("Write Logic to load the record");
}
public void ejbStore() {
System.out.println("Write Logic to store the record");
}

private Connection getConnection() {
try {
Context mContext = new InitialContext();
DataSource mDataSource = (DataSource) mContext.lookup("java racleDS");
return mDataSource.getConnection("matrix", "matrix");
}
catch (Exception vException) {
vException.printStackTrace();
}
return null;
}
}
When i deploy this bean the server gives me an error as -
Caused by: java.sql.SQLException: Column not found: ) in statement [CREATE TABLE
HELLOWORLD_BMP (CATAGORY_ID INTEGER NOT NULL, NAME VARCHAR(256), PARENT_ID INTE
GER NOT NULL, CONSTRAINT PK_HELLOWORLD_BMP PRIMARY KEY ())]
at org.hsqldb.Trace.getError(Trace.java:180)
at org.hsqldb.Result.<init>(Result.java:175)
at org.hsqldb.jdbcConnection.executeHSQL(jdbcConnection.java:907)
at org.hsqldb.jdbcConnection.execute(jdbcConnection.java:718)
at org.hsqldb.jdbcStatement.fetchResult(jdbcStatement.java:686)
at org.hsqldb.jdbcStatement.executeUpdate(jdbcStatement.java:85)
at org.jboss.resource.adapter.jdbc.local.LocalStatement.executeUpdate(Lo
calStatement.java:231)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.createTable(JDBCStart

I have specified the table name as 'CATAGORY'. But why does the server create a new table by some awkward 'HELLOWORLD_BMP' ?
Please help.... :roll:
Janarthan S
Yes Ajith,
That cleared a lot of misconceptions. I will get back with more qns as i progress. Please provide me with solutions as this one.
Thanking u,
JAnarthan S
I am 2 week old to EJB.
How do i wrap my entity bean with a session bean.
Eg : -
I am having a Entity bean EntityAccount.java and a session bean SessionAccount.java. Now i want to call the entity bean from this session bean. I don't want to use create method of entity bean. Is there any way by which i can call the entity bean without the create method ?
Please help me...
Janarthan S
HI,
I am 2 week old to EJB.
I am using jboss 3.0 as container.
I am using xdoclet for auto generation of code.
I have written an EntityBean "AccountBean.java" which reads as -
package helloworld;
import java.util.Collection;
import javax.ejb.SessionBean;
import javax.ejb.EntityContext;
/**
* @ejb.bean type="CMP"
* jndi-name="helloworld/Account"
* view-type="both"
* @ejb.finder signature="Collection findAllAccounts()"
* @ejb.pk
* @jboss:table-name "user_profile"
* @ejb:transaction type="Required"
*
*/

public abstract class AccountBean implements javax.ejb.EntityBean {
/**
* Create Account.
*
* @ejb.create-method
*/
public Object ejbCreate() throws javax.ejb.CreateException {
System.out.println("In ejbCreate()");
return new AccountPK();
//return null;
}
/**
* Create Account with parameters.
*
* @ejb.create-method
*/
public Object ejbCreate(String vUserIdentity,
String vFirstName,
double vPinCode
) throws javax.ejb.CreateException {
System.out.println("In ejbCreate() parametrised");
setUserIdentity(vUserIdentity);
setFirstName(vFirstName);
setPinCode(vPinCode);
System.out.println("returning AccountPK with acount NO " + vUserIdentity);
return new AccountPK(vUserIdentity);
//return null;
}
public void ejbPostCreate(String vUserIdentity,
String vFirstName,
double vPinCode
) throws javax.ejb.CreateException {
System.out.println("In ejbPostCreate() parametrised");
}
public void ejbPostCreate() throws javax.ejb.CreateException {
System.out.println("In ejbPostCreate()");
}

/**
* @ejb.pk-field
* @ejb.persistent-field
* @ejb.interface-method
* @jboss:column-name user_identity
*/
public abstract String getUserIdentity();
public abstract void setUserIdentity(String vUserIdentity);
/**
* @ejb.persistent-field
* @ejb.interface-method
* @jboss:column-name pin_code
*/
public abstract double getPinCode();
public abstract void setPinCode(double vPinCode);
/**
* @ejb.persistent-field
* @ejb.interface-method
* @jboss:column-name first_name
*/
public abstract String getFirstName();
public abstract void setFirstName(String vFirstName);
/**
* @ejb.interface-method
*/
public String accountInfo() {
return "Your account(change to pincode) has Rs. " + getPinCode() + " as balance";
}

}

Now to test this Entitybean, i wrote a class named "AccountClient.java" which reads as -
package helloworld;
import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import java.util.Properties;
import java.util.Vector;
class AccountClient
{
public static void main(String[] args)
{
System.out.println("\nBegin AccountClient ..\n");
try
{
// Create an Authentication object, in the server
Context ctx = new InitialContext();
System.out.println("context = " + ctx);
System.out.println("received context - now looking up \n");
Object obj = ctx.lookup("helloworld/Account");
AccountHome mAccountHome = (AccountHome) javax.rmi.PortableRemoteObject.narrow(obj, AccountHome.class) ;
System.out.println("before creating Account\n");
mAccountHome.create("user_001", "janarthan", 10500);
//mAccountHome.create("janarthan", 10500);
//mAccountHome.create();
System.out.println("after creating Account\n");
// Here is the call that executes the method on home objects find method
Vector mResult = (Vector)mAccountHome.findAllAccounts();
System.out.println("The result is " + mResult);
}
catch (Exception e)
{
System.out.println(":::::::::::::: Error :::::::::::::::::");
e.printStackTrace();
}
System.out.println("\nEnd Account...\n");
}
}

I compile and deploy the appln.Everthings OK.
I now run the AccountClient.java.
I get an exception as -
[java]
[java] Begin AccountClient ..
[java]
[java] context = javax.naming.InitialContext@888759
[java] received context - now looking up
[java]
[java] before creating Account
[java]
[java] :::::::::::::: Error :::::::::::::::::
[java] javax.ejb.CreateException: Error checking if entity exists:java.sql.SQLEx
ception: Column not found: USER_IDENTITY in statement [SELECT COUNT(*) FROM USER_P
ROFILE WHERE user_identity='user_001']
[java] at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.entityEx
ists(JDBCCreateEntityCommand.java:166)
[java] at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.execute(
JDBCCreateEntityCommand.java:127)
[java] at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JD
BCStoreManager.java:450)
[java] at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPer
sistenceManager.java:253)
[java] at org.jboss.resource.connectionmanager.CachedConnectionIntercepto
r.createEntity(CachedConnectionInterceptor.java:270)
[java] at org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:7
28)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccesso
rImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMetho
dAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:324)
[java] at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(E
ntityContainer.java:1116)
[java] at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractIn
terceptor.java:73)
[java] at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHo
me(EntitySynchronizationInterceptor.java:257)
[java] at org.jboss.resource.connectionmanager.CachedConnectionIntercepto
r.invokeHome(CachedConnectionInterceptor.java:215)
[java] at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(Enti
tyInstanceInterceptor.java:134)
[java] at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLo
ckInterceptor.java:79)
[java] at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(Enti
tyCreationInterceptor.java:44)
[java] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(Abstract
TxInterceptor.java:98)
[java] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIn
terceptorCMT.java:167)
[java] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptor
CMT.java:52)
[java] at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIn
terceptor.java:104)
[java] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.
java:109)
[java] at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:4
87)
[java] at org.jboss.ejb.Container.invoke(Container.java:726)
[java] at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1055)
[java] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java
:491)
[java] at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker
.java:362)
[java] at sun.reflect.GeneratedMethodAccessor131.invoke(Unknown Source)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMetho
dAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:324)
[java] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:
261)
[java] at sun.rmi.transport.Transport$1.run(Transport.java:148)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
[java] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.
java:460)
[java] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTra
nsport.java:701)
[java] at java.lang.Thread.run(Thread.java:536)
[java] at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(
StreamRemoteCall.java:247)
[java] at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall
.java:223)
[java] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
[java] at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknow
n Source)
[java] at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JR
MPInvokerProxy.java:128)
[java] at org.jboss.invocation.InvokerInterceptor.invoke(InvokerIntercept
or.java:108)
[java] at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterc
eptor.java:73)
[java] at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.
java:76)
[java]
[java] at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeIntercep
tor.java:185)
[java] End Account...
[java] at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
[java] at $Proxy0.create(Unknown Source)
[java]
[java] at helloworld.AccountClient.main(Unknown Source)
Please help me get out of this. I have not figured why this exception comes. The table that i am referring does contain 'USER_IDENTITY' as its field.
I have fought this for 2 days . Please help me !!!
I am using jboss 3.0.
I am 'new to' using xdoclet for code generation.
I have a finder method in my entity bean.
I want to specify the query for this method using xdoclet.
Table to query - user_table
Fields - username, password
My query in 'pure sql' is -
select username from user_table where username like '%user%'
I am not able to write this in EJB QL using Xdoclet.
Please help. :roll:
Janarthan S