schandu999

Greenhorn
+ Follow
since Feb 07, 2002
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 schandu999

David
the class.forname is used for the loading the class runtime.
for example if i don'nt know the driver to be loaded at compile time then its ok to use.
But if I know before compile time driver to be used then i don't feal there is any use of that.
I can just create a new instance of the class
like
Driver d = new sun.jdbc.odbc.JdbcOdbcDriver();
instead of
DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(DRIVER);
and this code also works.
Hi ,
Why it required to follow the normal jdbc steps for getting the connectiion as

#1
Driver d = (Driver)(Class.forName( DRIVER ).newInstance());
DriverManager.registerDriver(d);
#2
Connection conn = DriverManager.getConnection (DBURL, username, pwd);
#3
Then u get the connection and execute the SQL statements
But the same we can do this way
PLs tell me what is wrong in this way , why i am calling it wrong way coz never seen ppl doing this way

Thanks
[ Edited by Dave to format code and fix smilies ]
[ April 01, 2002: Message edited by: David O'Meara ]
'Now the Q ?: is this right way ?? I have seen the
codes all SQL operation at Java Bean end including Firing of SQL and sends back the ResultSet abck to JSP and close RS in JSP. Just by closing RS will it make sure all related objects incl Conn. got closed ie send back to pool. Or should i send this RS back to JavaBean and get related Statement Obejct (RS.getStatement) and Conn obj(Stmt.getConenction) and close all there at Java end '
Hi sandya ,
by just closing the rs won't close the stmt and conn objet.
One suggetion instead of sending rs back , why don't u close u r rs,stmt,conn obj in the bean only,
and close first resultset, statement and then close your connection object in the finally
like this


let me know if this workd for u or not
thanks
champak
[ Edited by Dave to format code ]
[ February 15, 2002: Message edited by: David O'Meara ]
Hi,
For this use Callable cstmt as
CallableStatement cstmt = null;
or
CallableStatement cstmt = conn.prepareCall("{call Proc_name(?,?,?,?)}");
then set the IN params in the proc using set methods as setInt ,setString
and out as
cstmt.registerOutParameter(2, java.sql.Types.INTEGER);
(here 2 -> parameterInedex and java.sql.Types.INTEGER as -> sql type)
there are methods also registering the out parameters see it in java doc
then execute the proc as
cstmt.execute();
In the end close cstmt , conn in the finally block
thanks
champak
hi Graeme ,
Thanks for the reply , but can u please let me know the difference between the process of class loaders and new object creation ?
Thanks
Champak
hi
There may be problem in your conn , see whether this object is getting created or not , Coz if
conn.rollback();
is throwing the exception then check it with null
pls see the code below
thanks

catch (SQLException e) {
try{
//*****************
if(conn != null)
//****************
conn.rollback();
Logger.logProblem();
}
catch (SQLException sqle) {
String name = "Errror in trying to rollback:" + new java.util.Date();
Logger.logProblem(name);
}
catch (SQLException sqle) {
String name = " SQl Errror:" + new java.util.Date();
Logger.logProblem(name);
}
}
The Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
is used load the class run time.
A new Object creation does the same .
Then what is the excat difference between these two.
The JdbcOdbcDriver class has static method where it registers the driver DriverManager.registerDriver(jdbcodbcdriver);
If I can call the same stuff using the object why i need the class loader ?
thanks
63= 111111111111111111111 (bin)
& (binary & operator)
4= 00000000000000000100 (bin)
------------------------------
000000000000000000100 = 4
as 1&1=1
1&0=0
0&1=0
0&0=0
the Answers are 21: b
22: b

B'cause in first one the casting wont take plac as these are the objects not premitives.
for the other one the referance is compared not the value.
hope this may help u.