smitha rai

Greenhorn
+ Follow
since Jun 29, 2001
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 smitha rai

Hi,

I have an employee data available in the database and need to display the employee info hierarchy on a JSP (like an organizational chart).

Is there any open source available to display?

Appreciate for a suggested solution.

Thanks in advance,

Smitha
13 years ago
Now the javax.naming.CommunicationException exception is gone when I add classes12.jar to the classpath. The new exception I see as below:

java.lang.NoClassDefFoundError: com/ibm/db2/jcc/DB2Wrapper
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:703)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:133)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:320)
at java.net.URLClassLoader.access$400(URLClassLoader.java:93)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:239)
at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:460)
at java.lang.ClassLoader.loadClass(ClassLoader.java:448)
at com.ibm.ws.rsadapter.ObjectCache.<init>(ObjectCache.java:58)
at com.ibm.ws.rsadapter.ObjectCache.<clinit>(ObjectCache.java:53)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.<clinit>(WSRdbManagedConnectionImpl.java:291)
at com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl.createManagedConnection(WSManagedConnectionFactoryImpl.java:532)
at com.ibm.ejs.j2c.poolmanager.FreePool.createManagedConnectionWithMCWrapper(FreePool.java:1226)
at com.ibm.ejs.j2c.poolmanager.FreePool.createOrWaitForConnection(FreePool.java:1032)
at com.ibm.ejs.j2c.poolmanager.PoolManager.reserve(PoolManager.java:1680)
at com.ibm.ejs.j2c.ConnectionManager.allocateMCWrapper(ConnectionManager.java:665)
at com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:453)
at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:215)
at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:190)

Any suggestions greatly appreciated.
13 years ago
Hi Vijay,

Yes, I could be able to establish the connection using the driver manager ang get the results.

No luck yet.

Smitha
13 years ago
Thanks Ratan,

Yes, I can access to the database. The database server is fine.

Smitha
13 years ago
Hi Gurus,

I have configured the datasource on WebSphere v5.0 Test Environment and trying to access it from the stand alone client (say, a JUnit test class) in a java project. When I execute the test class, I get the following error.

Appreciate your help and suggestions.

Smitha
==========================================================================
javax.naming.CommunicationException: A communication failure occurred while attempting to obtain an initial context with the provider URL: "iiop://localhost:2809". Make sure that any bootstrap address information in the URL is correct and that the target name server is running. A bootstrap address with no port specification defaults to port 2809. Possible causes other than an incorrect bootstrap address or unavailable name server include the network environment and workstation network configuration. Root exception is org.omg.CORBA.COMM_FAILURE: WRITE_ERROR_SEND_1 minor code: 49421050 completed: No
at com.ibm.ws.orbimpl.transport.HTTPOutputStream.write(Unknown Source)
at com.ibm.rmi.iiop.IIOPOutputStream.writeTo(IIOPOutputStream.java:283)
at com.ibm.rmi.iiop.Connection.send(Connection.java:1485)
at com.ibm.rmi.iiop.Connection._locate(Connection.java:265)
at com.ibm.rmi.iiop.Connection.locate(Connection.java:244)
at com.ibm.rmi.iiop.GIOPImpl.locate(GIOPImpl.java:184)
at com.ibm.rmi.corba.Corbaloc.locateUsingINS(Corbaloc.java:305)
at com.ibm.rmi.corba.Corbaloc.resolve(Corbaloc.java:367)
at com.ibm.rmi.corba.ORB.string_to_object(ORB.java:2941)
at com.ibm.ws.naming.util.WsnInitCtxFactory.stringToObject(WsnInitCtxFactory.java:1256)
at com.ibm.ws.naming.util.WsnInitCtxFactory.mergeWsnNSProperties(WsnInitCtxFactory.java:1107)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootContextFromServer(WsnInitCtxFactory.java:679)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootJndiContext(WsnInitCtxFactory.java:607)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:482)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:112)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:422)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:143)
at javax.naming.InitialContext.lookup(InitialContext.java:359)
at org.kp.sql.helper.DataSourceUtil.initializeDataSource(DataSourceUtil.java:90)
at org.kp.sql.helper.DataSourceUtil.getDataSource(DataSourceUtil.java:61)
at org.kp.sql.helper.CommonDAO.retrieveListFromDB(CommonDAO.java:79)
at org.kp.message.dao.impl.MessageDAOImpl.retrieveMessage(MessageDAOImpl.java:89)
at org.kp.message.service.impl.MessageServiceImpl.retrieveMessages(MessageServiceImpl.java:258)
at org.kp.message.service.impl.MessageServiceImpl.findMessage(MessageServiceImpl.java:65)
at org.kp.message.util.MessageServiceUtil.getMessage(MessageServiceUtil.java:72)
at org.kp.message.test.TestMessageManager.main(TestMessageManager.java:10)
Exception in thread "P=801061 =0:CT"
===========================================================================

The following jars added in the classpath for the java project.
--------------------------------------------------------------
1. ivjejb35.jar
2. j2cImpl.jar
3. j2ee.jar
4. naming.jar
5. namingclient.jar
6. webcontainer.jar
7. j2c.properties
8. implfactory.properties

Following is the code I am using to get the DataSource:

private DataSource getDataSource(String jndiName) throws NamingException{
DataSource ds = null;
InitialContext context = null;
try {
Properties prop = new Properties();
prop.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
prop.put(javax.naming.Context.PROVIDER_URL, "iiop://localhost:2908");
context = new InitialContext(prop);
ds = (DataSource) javax.rmi.PortableRemoteObject.narrow(
context.lookup(jndiName),
DataSource.class);
} catch (ClassCastException ne) {
//Handle exception
}
return ds;
}
13 years ago
I have concerns over passing DataSource object in a method. Rather, can the client (ClassA) create a datasource object and pass it to other method (in a classB)?

Thanks in advance,

Example:

public classA {

public static List getData() {
return new ClassB().getData(createDataSource());
}

private static DataSource c{
//Create a datasource object (ds) based on the
//database connection parameters
return ds
}

} //classA

public classB {
public List getData(DataSource ds) {
//Establishes connection gets the
//resutset and processes it and
//returns a List of data
}
} //classB
13 years ago
How do I get a yesteday's date in java.sq.Date format? Appreciate if someone would provide me a sample code.

Tnx

Smitha
14 years ago
Hi I am in a process of testing a web application. I do not have an idea on URL butchering. Can any one advise me on what is URL butchering? and how is exactly done?

Thannks a lot,

Smitha
15 years ago
I have an arraylist which contains data fetched from database. I want to display all these results in a jsp in a shot of 10 results at a time. The jsp contains two buttons namely, next and previous. Can any one help me out with a code or some tips. It is quite urgent for me please.......
19 years ago
Hi,
I want to create a hash objects with names which are stored in a vector. I could not able to succeed the following code. Can any one help me out please.
Smitha
=================================================================
//package utils;
import java.util.*;
import java.sql.*;
public class HashTable1 {
double dBooks = 0.0;
double dTelephone = 0.0;
double dRent = 0.0;
double dTravelling = 0.0;
double dEntertainment = 0.0;
double dMedicine = 0.0;


public Vector getPayMethods() {
Vector vec = new Vector();
vec.add(0,"abc");
vec.add(1,"xyz");
vec.add(2,"pqr");
vec.add(3,"mno");

return vec;
}

public void initHashTables(){

Vector vec = new Vector();
vec = getPayMethods();
for(int i=0; i < vec.size(); i++) {



Hashtable vec.elementAt(i) = new HashTable();
(vec.elementAt(i)).put("Groceries", new java.lang.Double(dBooks));
(vec.elementAt(i)).put("Telephone", new java.lang.Double(dTelephone));
(vec.elementAt(i)).put("HouseRent", new java.lang.Double(dRent));
(vec.elementAt(i)).put("Travelling", new java.lang.Double(dTravelling));
(vec.elementAt(i)).put("Entertainment", new java.lang.Double(dEntertainment));
(vec.elementAt(i)).put("Medicine", new java.lang.Double(dMedicine));
}
}

public static void main(String[] args) {
Hashtable1 ht = new HashTable1();
ht.initHashTables();
System.out.println("Size of Hash Table abc : " + abc.size());
System.out.println("Size of Hash Table xyz : " + xyz.size());
System.out.println("Size of Hash Table pqr : " + pqr.size());
System.out.println("Size of Hash Table mno : " + mno.size());
}
}
19 years ago
Hi,
I have an application which is to be made to fit into 600 x 800 size. Can any one help on this please?
Hi,
I am having problem with inserting a row into the MsAccess Database. I am getting error like
"SQLException: Occurred while performing Database Operations ---> method Main() java.sql.SQLException
: [Microsoft][ODBC Microsoft Access 97 Driver] Syntax error in INSERT INTO statement.[Microsoft][ODB
C Microsoft Access 97 Driver] Syntax error in INSERT INTO statement".
My code is as under:
please help me out.
Smitha
==========================================
package dao;
import utils.GeneralFailureException;
import dbConnection.dbConnection;
import java.util.*;
import java.sql.*;
public class GeneralExpenses {
dbConnection dbCon = new dbConnection();
public GeneralExpenses() {
super();
}

public static java.sql.Timestamp getTstamp() {
java.util.Date date = (Calendar.getInstance()).getTime();
java.sql.Timestamp tStamp = new java.sql.Timestamp(date.getTime());
System.out.println("The Time Stamp : " + tStamp);
return tStamp;
}
public void insertExpenseTable(String sExphead, double dAmount, String sMode)
throws GeneralFailureException, SQLException, ClassNotFoundException {
String inssql = "INSERT INTO EXPENSES(tnum, date , " + sExphead + ", " + sMode + ") VALUES(?,?,?,?)";
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = dbCon.getConnection();
pstmt = conn.prepareStatement(inssql);

pstmt.setInt(1, 100);
pstmt.setTimestamp(2, getTstamp());
pstmt.setDouble(3, dAmount);
pstmt.setString(4, sMode);

pstmt.executeUpdate();
} finally {
dbCon.closeAll(pstmt, conn);
}
}
public static void main(String[] args) {
try {
GeneralExpenses ge = new GeneralExpenses();
ge.insertExpenseTable("xxxxxxx", 250.35, "yyyyyyyy");
System.out.println("worked");
} catch(ClassNotFoundException sqlex) {
System.err.print("SQLException: Occurred while performing Database Operations ---> method Main() " + sqlex);
System.err.println(sqlex.getMessage());
}
catch(SQLException sqlex) {
System.err.print("SQLException: Occurred while performing Database Operations ---> method Main() " + sqlex);
System.err.println(sqlex.getMessage());
} catch(GeneralFailureException e) {
System.err.print("GeneralFailureException: Occurred while Establishing Connection ---> method getConnection() " + e);
System.err.println(e.getMessage());
} catch(Exception e) {
System.err.print("GeneralFailureException: Occurred while Establishing Connection ---> method getConnection() " + e);
System.err.println(e.getMessage());
}
}
}
Thanks Prathima, I got it.
Smitha
Hi Yudi,
You may get some clues from the following code. Please note that in the code "JDBCMsAccessConnection" represents a class that establishes connection to the database.
Good luck,
Smitha
================================================================

import java.util.*;
import java.sql.*;
import java.lang.*;
import java.text.*;

public class DateTest_MsAccess{


public static java.sql.Timestamp getTstamp() {
java.util.Date date = (Calendar.getInstance()).getTime();
java.sql.Timestamp tStamp = new java.sql.Timestamp(date.getTime());
// OR java.sql.Timestamp tStamp = new java.sql.Timestamp(System.currentTimeMillis());
System.out.println("The Time Stamp : " + tStamp);
return tStamp;
}


public void insertData() {

Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
Calendar cal = Calendar.getInstance();

JDBCMsAccessConnection joc = new JDBCMsAccessConnection();

try {

con = joc.getAccessConnection();

con.setAutoCommit(false);

java.util.Date myDate = new java.util.Date();
java.sql.Date sqlDate = new java.sql.Date(myDate.getTime());

String query = "INSERT INTO TESTING VALUES(?,?,?)";
pstmt=con.prepareStatement(query);
pstmt.setInt(1,600);
pstmt.setTimestamp(2, getTstamp());
// U can also use the following statement which inserts only time
//pstmt.setDate(2, sqlDate);
pstmt.setString(3,"CCCC");
pstmt.executeUpdate();

con.commit();


} catch(SQLException ex) {
System.err.println("SQLException Occurred in method insertData() : " + ex.getMessage());
ex.printStackTrace();
} catch(Exception e){
System.out.println("Exception Occurred in method insertData() :" + e);
}
finally {

joc.closeAll(pstmt, con);

}
}
public void ReadData() {

Connection con = null;
Statement stmt = null;
ResultSet rs = null;

JDBCMsAccessConnection joc = new JDBCMsAccessConnection();

try {

con = joc.getAccessConnection();
stmt = con.createStatement();

java.util.Date dt = new java.util.Date();

String query = "select * from testing";


con.commit();
rs = stmt.executeQuery (query);

while (rs.next()) {
System.out.println(rs.getInt(1) + " " + rs.getString(2) + " " + rs.getString(3));


}

} catch(SQLException ex) {
System.err.println("SQLException Occurred in method ReadData() : " + ex.getMessage());
ex.printStackTrace();
} catch(Exception e){
System.out.println("Exception Occurred in method ReadData() :" + e);
}
finally {

joc.closeAll(rs, stmt, con);
}
}

public static void main (String args[]){

java.util.Date dat = new java.util.Date();
System.out.println("Current Date is : " + dat.getTime());

DateTest_MsAccess dT = new DateTest_MsAccess();

dT.insertData();
dT.ReadData();

}
}

================================================================