jeff zhang

Greenhorn
+ Follow
since Sep 25, 2000
Merit badge: grant badges
For More
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 jeff zhang

Hello,
I have an oracle 8.1.6.2 installed on my solaris system. Recently, I downloaded a jdbc driver oracle8i 8.1.6.2.0
from the oracle site and encounted the following problems
when using prepareStatement:
If the sql Statement has two table join, using setString
will not work(no any exception caught, but did not get any
data from db). If the parameter values were hard-coded
insided the sql statement instead of using setString, the
prepareStatement.executeQuery() will get some data returned
from the database. I also tried the jdbc driver for oracle 8.1.7
and got the same result. When I switched back to my old
classes111.zip(not for 8.1.6.2 and 8.1.7), everything is ok.
But the old classes111.zip will not support jdbc20 features.
Can anybody tell me what are problems and how to solve those?
Your help is greatly appreciated!
Thanks,
Jeff
p.s. both jdk1.2.2/lib and jdbc/classes12.zip are set in the CLASSPATH.
//test code

import java.sql.*;
public class driverTest
{
public static void main(String[] args)
{
PreparedStatement ps = null;
Connection my_conn = null;
try
{
//load the driver class
Class.forName("oracle.jdbc.driver.OracleDriver");

// making a conn through the Drivermanager
my_conn =DriverManager.getConnection
("jdbc racle:thin:@myDbServer", userId, password);
ps = my_conn.prepareStatement(
"SELECT a.column1 " +
"from TableA a, TableB b " +
"where a.comColume = b.comColumn " +
"and a.col2 = ? " +
"and a.col3 = ? ");
ps.setString(1, "value1");
ps.setString(2, "values");

ResultSet rs =ps.executeQuery();

while (rs.next()) {
System.out.println(" ***return the following from db");
System.out.println(" column1 = " + rs.getString(1));

}
}
catch(ClassNotFoundException cnfe)
{
System.err.println(cnfe);
}
catch(SQLException sqle)
{
System.err.println(sqle);
}

finally {
try { if(ps != null) ps.close(); }
catch (SQLException sqle) {
System.out.println("Error closing ps. " + sqle.getMessage());
}
try { if(my_conn != null) my_conn.close();
System.out.println("Connection closed.");
}
catch(SQLException sqle) {
System.out.println("Error closing database connection. " + sqle.getMessage());
}
}
}
}
Jim,
I did, but no help.
Thanks,
Jeff
Hi,
When I tried to run a BatchUpdate command(executeBatch())
and got the following error info if the unique constraint
was violated.
getErrorCode() = 17081
getMessage() = error occurred during batching: ORA-00001: unique constraint (AWS.USERS_LOGIN_PK) violated
The SQLException was caught and the getErrorCode() returned 17081,
but not 1. Why?
Any help?
Thanks
Jeff
Hi,
I have a BME bean which is supposed to provide services to
outside calls. The bean needs to access two different database
servers for some of its method invocations. I tried to use
a flag value inside ejbLoad() to determine which server the persistence fields should come from. But, I did not get what I
expect due to wrong flag value. Can anybody help me?
Thanks,
Jeff
The following is a pieces of codes:
public void ejbLoad()
{
BeanPK (BeanPK) context.getPrimaryKey();
Connection con = null;
if (flag = 1)
{
con=this.getConnectionA();
.....
}
else if (flag = 2)
{
con=this.getConnectionB();
.....
}
....
}
The flag is an instance variable and was set in methods like
findByPrimaryKey(), findFromdbA(), and findFromdbB(). If caller
invokes findFromdbA() and findFromdbB() alternatively, the wrong
flag value will be seen.
Thanks for responses. All suggestions can work around '&' problem. Especially, Jay's CDATA solution is the one I am looking for since I may have many special chars like '&' or '<' needed to handle. After I posted the question, I realized what's wrong in my previous xml stream. I should not put <![CDATA[ after <orders> since it will violate the rule defined in dtd file(get error like Element "orders" does not allow text.).
Thanks again for all your help.
Jeff
Hi All,
I tried to parse the following xml data with sun's dom validating parwer. But I got the error like:
Element "orders" does not allow text.
The xml data is:
<?xml version ="1.0"?><!DOCTYPE orders [
<!ELEMENT orders (order+)>
<!ELEMENT order EMPTY>
<!ATTLIST order
customerName CDATA #REQUIRED
customerAddr CDATA #IMPLIED >
]>
<orders><![CDATA[<[order customerName= " mark & john " customerAddr= "route 15">
</order>]]></orders>
I have no ideas what's wrong there.
Can anybody help?
Thanks in advance
Jeff
Jay,
It is working now after ErrorHandeler configured.
Thanks,
Jeff
Hi,
I tried to read an xml data with validating the input. But the
validation did not seem to do its job. Can anybody help to point
out what is problem? Your help is appreciated.
The following are codes and xml data:


<order>
<customerName>tester</customerName>
</order>
When I run the program and it did not complain on wrong tagName.
Anything wrong in above codes?
-- Added UBB CODE tags to aid code readability
[This message has been edited by Frank Carver (edited September 29, 2000).]