Win a copy of Java Challengers this week in the Java in General forum!

Vin Man

Greenhorn
+ Follow
since Jun 13, 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 Vin Man

hi,
how do your programmatically start a new http session?
18 years ago
Hi,
Does anyone know where can I find the class javax.media.jai.RenderedOp? I am using jdk 1.3 and got a run-time error java.lang.NoClassDefFoundError: javax.media.jai.RenderedOp
TIA...
Vin Man
18 years ago
hi,
is there any way servlet can manipulate the content of an existing dpf document and display it to a browser (by foreward())?
18 years ago
Hi Jan,
Thanks for the posting of the link to the Ohio Dot open source project.
I tried running their hello2 and hello3 example - pretty much like what you did in your "myClass" servlet. My hello2.java code follows:
public class hello2 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/pdf");
PdfPage page = new PdfPage(response.getOutputStream());
page.setFont(page.BOLD, 50);
page.println("Tutorial - Hello 2");
page.setFont(page.NORMAL, 25);
page.println(new Date().toString());
page.close();
}// doGet()
}// end of class
after deploying the servlet to my jrun servlet engine and restarting it, I type in the address to my servlet on my IE address bar (eg. http://localHost/test/servlet/sutut1.hello2). What I am getting is a blank page!!! Did you run into this problem? and what did you do to get your content displayed?
18 years ago
Jamie,
Thanks for your response.
I did find that the statement.close() method does release any Oracle and JDBC resource involved. Of course, as you have stated, one would need to store the resultset into some collection object prior to doing so.
I also found another bazzard thing - if you access your database using the connection.callableStatement, you would leave some dangling opened cursor in your Oracle server even if you close your callableStatement!!! I have included my code for illustration:
...
...
Connection con;
CallableStatement cs;
try{
con = getDBConnection();
cs = con.prepareCall(
"{? = call checkPriv(" +
userID + ")}");
try{
cs.registerOutParameter(1, java.sql.Types.INTEGER);
cs.execute();
canUpdate = (cs.getInt(1) >= 0);
}
finally{
cs.close();
if (con != null)
returnConnectionToPool(con);
}
As you see cs.close() is guaranteed to run, but the implicitly opened cursor by the sql inside checkPriv() are still left dangling in Oracle v$open_cursor!!!
Let me know if you experience differently.
thanks.
Hi,
In my application, I have a JDBC connection which I create and re-use over and over. The connection is used to execute sql statement, whose resultset is stored in bean object. So the sequence of executing an SQL is as outlined below:
.
.
.
String sql = "select customerName, address from customer";
Connection connection = getPreviouslyCreatedconnection(); // returns valid connection
Statement statement = connection.createStatement();
storeResultSetInBean(statement.executeQuery(sql));
.
.
.
everything is working as expected - for a while any way.
The problem is each time a sql is executed, an oracle session is created to hold the implicitly opened oracle cursor, and it remains open as long as the connection is opened!!! So my application can only operate until the maximum number of cursors defined by Oracle is reached, at which point I will get ora###-Maximum cursors reached when I try to execute an sql. I don't really want to close my connection each time I need access to the db, as it can slow down my app.
I have tried the statement.close() at the end of each sql operation, but that seems to close the connection as well.
Thanks in advacne for any idea how to get around this problem...
hi,
I have a stored function named HasAccess(UserID_in IN CHAR) return boolean, which is compiled and tested properly in SQLPlus. I am attempting to call the stored function in a java program as follows:
class xyz {
public boolean isUpdatable(String userID){
Connection con;
CallableStatement cs;
boolean zzz;
try{
con = getDBConnection();
try{
cs = con.prepareCall(
"{? = call HasAccess('Vinman')}");

cs.registerOutParameter(1, java.sql.Types.OTHER);
System.out.println("registered out param");
cs.execute();
System.out.println("executed the stored procs");
}
finally{}
}
catch(Exception e){
System.out.println("problem getting access privs of user "
+ userID + ". and the problem is " +
e.getMessage());
}
return zzz;

}
During run-time, my program failed on the line where I am trying to registered the return varaiable (cs.registerOutParameter(1, java.sql.Types.OTHER);
), and e.getMessage() is "ORA-06550: line 1, column 13:
PLS-00382: expression is of wrong type
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored.

What type should I use in the registered method?
Thanks in advance...
forgot to include the output in my previous example... Here it is:
---- BEFORE s is before update
--------AFTER s is before update
18 years ago
Junilu,
Thanks for your advice. I followed your example and it worked!
I thought I read somewhere that for anything to be passed by reference, it has to be of some object types. So out of curiosity, I made mine (before changing it to an array of string) to be of type Object, but apparently that was not right. See code and output below. Wonder what is going on there...
private static void zzz(Object strObj){
strObj = new String ("should see this now");
}
public static void main(String[] a)
{
//String[] s = {"before update"};
Object s = new String("before update");
System.out.println("---- BEFORE s is " + (String) s);
zzz( s );
System.out.println("--------AFTER s is " + (String) s);
}
...
18 years ago
Hi,
Can anyone please tell me how to pass a string by reference, as I might have to change the content of the string within the called function. Thanks in advance.
18 years ago
all,
Thanks for all the reponses! I have learned a great deal from this...
18 years ago
hi Anil,
you might want to check out the following post: https://coderanch.com/t/354533/Servlets/java/servlet-jsp
hope it helps...
18 years ago
Gustavo,
Thanks for the reference to the unicode...
I took your suggestion did some test print, and my tests result as follows: Character.getNumericValue('A')=10
Character.getNumericValue('z')=35
Character.getNumericValue(' ')=-1
.
.
And then I looked at the code chart at the site you mentioned, and the codes for 'A', 'z', and ' ', respectively, are '0041', '007A', and '0020'. How are they converted?
18 years ago
Thanks for the reponse, Sandy!
First of all, for my application, space is meaningful and critical in querying the correct data (ok. I didn't build the database). So I want to preserve the spaces around the options. Secondly, when my form is posted, the parameter obtained from the selection list, in our example, is not " 29" (space, space, 29), but something else; I have printed out the SQL from my servlet, copied it out to a SQLPlus session, run it, and it returns no resultset. If I deleted those 2 unknown characters and put in two spaces, my SQL would returns records as expected. So I think the "nbsp" is posted as something other than a space. Is there a way to evaluate the ascii value of a charater?
18 years ago