Surendran Velath

Greenhorn
+ Follow
since Apr 23, 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 Surendran Velath

I looked at the InputStream again. Printed it before and after unmarshalling and found that it was empty the second time.
So commented out the first printing and got proper results.
Got to be careful when reading from streams. When I printed the value from the stream, it got flushed out. So the unmarshaller got an empty stream to work with.

Thanks Paul, Thanks Bill

Surendran
Here is the code:

Thanks
Surendran
Thanks for the reply Bill.

I am printing the InputStream on the console and is as shown under XML recieved. So it is clear that the 'is' is not empty.
Someone told me that there may be extra characters at the beginning and end of the stream. But I checked and it is not so.

Surendran
A HAPPY NEW YEAR TO EVERYONE.

I am using Castor to parse the XML recieved as InputStream

The xsd used to generate the java classes are as follows:

[ dn_translation_result.xsd ]


[ enrichment_result.xsd ]

The XML recieved is :

The following code throws an exception as below:

where 'is' is the XML InputStream. I tried this with FileInputStream also, with same result.

Can anyone help me out in solving this issue?

Thanks
Surendran
[ January 01, 2006: Message edited by: Surendran Velath ]
There is no limit to the number of statements that can be created from a Connection
Here is a brief note that I had prepared some time back. Hope it will be useful:
Need for Indexes
An index placed on a table helps to retrieve data faster.
A well placed index makes the application run faster when accessing the data.
This is possible because the Database engine looks at the index instead of the column when a select statement is fired on that column.
The buffer can hold more number of rows since the db engine does not go through all the columns of the table.
If more than one column is to be selected, then concatenated indexes are used. Indexes are sorted and can be unique.
Indexing is used in case of a search within the database
The following are the rules for indexing:
� The columns mentioned in SQL statement predicates ( the 'where' or 'and' selections ) should be indexed
for example : SELECT a.age, a.name WHERE a.id='P991';
If column 'id' was indexed, the DB engine looks for id='P991' in the index which is ordered and quickly finds the location through the rowid in the corresponding table. Else search has to be made from start to 'P991' till the record is found.
� If a column has a large number of distinct values (not repeated) it is a candidate for indexing.
� If multiple columns are continually referenced together in SQL statement predicates, these columns should be put together in a composite index.
� The section under IN, NOT IN, EXISTS are not indexed.
� The columns in the join condition of two tables are indexed.
-- Surendran
I have a machine which works on Windows 2000 with two CPUs
My JVM has a number of threads running full capacity all the time which makes the CPU go above 70%. But is there any way the other CPU can share the load? May be some of the threads can be diverted to the other CPU.
If it is not possible for the JVM to share the CPUs, is there a way I can force the operating system to make use of the other CPU to share the load after say 50% capacity of the first CPU?
I need to enhance the peformance of my JVM
Please help me out with the multiple CPU sharing issue
Thanks
setAutoCommit false
If you are firing queries one row at a time
put a counter initialised to zero in the loop and increment it by one
When the counter reaches 10000, fire commit() and set the counter to zero
Continue till all records are inserted and fire commit in the finally block
You may use -
DriverManager.setLoginTimeout(seconds)
to increase the wait time
Also
Tune the connection pool and database as per requirements of your application
You may retry the getConnection() but is not advisible
conn.close() closes all your statements and resultsets automatically
Hi Anushree,
Since you have MS SQL installed you need the JDBC driver for that database
I use AvenirDriver :
The class is: net.avenir.jdbc2.Driver
These are thin drivers and vendor specific.
Get the jar file for this driver and set your classpath to it.
Then you can use your JDBC application to interact with this database
good luck
If you know it is the third procedure for sure then you can ignore the first two after fetching the ResultSets.
If not, then use a condition that is returned by your ResultSet to make sure it is the one you want.
Any way you will get the ResultSet in the order of appearance of SELECT statement inside the Procedure
Hi Ashish,
Use the following code for any number of result sets returned from the procedure:
(Each select statement returns one resultset)
private Connection conn;
private CallableStatement cstt;
private ResultSet rs;
try
{
Class.forName( driver ).newInstance();
conn = DriverManager.getConnection(URL , user, pswd );
cstt = conn.prepareCall( "{call testproc()}" );
cstt.execute();
try
{
// cstt.getObject( 1 ); // for out params
rs = cstt.getResultSet();
ResultSetMetaData rsmd = rs.getMetaData();
int cols = rsmd.getColumnCount();
while(rs.next())
{
for(int i=0; i<cols; i++)
System.out.print(rs.getString(i+1)+", ");
System.out.println();
}
while(cstt.getMoreResults())
{
System.out.println( " Next:");
rs = cstt.getResultSet();
rsmd = rs.getMetaData();
cols = rsmd.getColumnCount();
while(rs.next())
{
for(int i=0; i<cols; i++)
System.out.print(rs.getString(i+1)+", ");
System.out.println();
}
}
}
catch(SQLException sqe)
{
System.out.println( " No value got from stored procedure" );
sqe.printStackTrace ();
}
}
catch( Throwable e )
{
e.printStackTrace();
}
When you say
In the expression:
pstt = con.preparedStatement("update table1 set col1=?,col2=? where id= ?");
each ? is supposed to be bound by a value against a database column
so
pstt.setObject(1, obj);
will set obj as the value for col1 and so on
Within the obj we cannot put a ? and bind it to the statement
You can use a Statement also
stmt.executeUpdate("test''s"/"test&s"/"test\s");
only remember that a single quote needs an additional single quote
test''s
all other characters are accepted directly
Hi Jack,
It's nice to hear about your book
Java Performance Tuning
I've always wanted to get my hand on a good book on Performance tuning. It will be of great help to programmers in Java.
Thanks,
Surendran
Sun Certified Programmer for Java 2
19 years ago