rasit fidanov

Greenhorn
+ Follow
since Jun 30, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by rasit fidanov

what is the goal of executeBatch?
Is it faster?
is it faster than preparedStatement too?
Another question is can i batch how many times i want, in statement or p.statement?

Is there limit for it?
In previous question too is there a limit of rolling back?
I have some more questions.
suppose that we have a prepared statement and we update some values with it in a loop.

loop has big number of looping.for example 100000;

with autocommit false we do commit manually and if there is something going wrong we can rollback it in catch block.
so will everthing be ok when an exception occures in 99000. of loop?

can it rollback all it did.

is there a size of it to rollback?

how is it working in fact ?
rolback mechanism?
[ July 12, 2005: Message edited by: rasit fidanov ]
ahaaaa.

Thats just what i want...

This is much more tender way to find out whether it was null or not.

thank you.

How lucky i am, i met javarunch by chance.I am learning here more and more day by day.

Thank you all ,i will have more questions in future too.
Hi again,

Thank you for your answer.However, there is not isNull() method in Resultset interface?
Or i could not see?i checked it carefully from javadoc, but i could not see it.
Which version of java did you tell me?java 5.0?

We still have to use 1.4 for J2EE as you know.

Ummm i checked 5.0 too from sun's site's javadoc.I could not see the method.

Its too important for me.Because i try to check with getString method of ResultSet whether a value is null or not .It returns null for an Number column.

I dont like this way..

There must be a better way to check it.
I have a problem with Null value passed in a column of oracle table.

How can i get and set a NUMBER column with a NULL value.

if i try to get a record having Null value ResultSet's getInt() method returns 0 !?..

And setting a column with Null, how to do it using PreparedStatement and Statement?
sorry as i added my reply under this topic and could not see.I created a new topic.

And added some at the end too.
Can you read Statement vs. Preparedstatement topic?
I have read about PreparedStatement and Statement's performances too.

and i wanted to see the difference byself.
So in oracle db i've created a table having 2 numbers and 1 varchar column.

And i ran an insert sql into test table in a loop of 5000 times.
and i measured the time with System.currentTimeMillis();

before and after the loop to demonstrate PreparedStatement had better performance.

I tested it several times.

At first Statement finished jobs with the 89 secs.

PreparedStatement finished with 49 seconds.

as i told i tested it several times.

then more and more Statement closed the difference of time
between PreparedStatement.

Can any body explain this stuation?

My friend That he doesnt understand any java but he knows oracle very well explained me that with "oracle forms" if an sql statement sent to db then it compiles it only for once and executes the compiled sql if asked for again...

Does oracle do some trick at db side to reduce the compilation time?

I wonder whether the execution sql sent is in same format and only taking the different paramaters, Oracle may understand it and pulls it from sql string and embeds to precompiled sql and executes it?

Can anybody explain me why Statement reduced the difference between PreparedStatement?
[ July 07, 2005: Message edited by: rasit fidanov ]
I have read about PreparedStatement and Statement's performances too.

and i wanted to see the difference byself.
So in oracle db i've created a table having 2 numbers and 1 varchar column.

And i ran an insert sql into test table in a loop of 5000 times.
and i measured the time with System.currentTimeMillis();

before and after the loop to demonstrate PreparedStatement had better performance.

I tested it several times.

At first Statement finished jobs with the 89 secs.

PreparedStatement finished with 49 seconds.

as i told i tested it several times.

then more and more Statement closed the difference of time
between PreparedStatement.

Can any body explain this stuation?

My friend That he doesnt understand any java but he knows oracle very well explained me that with "oracle forms" if an sql statement sent to db then it compiles it only for once and executes the compiled sql if asked for again...

Does oracle do some trick at db side to reduce the compilation time?

??
[ July 07, 2005: Message edited by: rasit fidanov ]
Thank you for the answer..

in java side garbage collectors will collect non-referenced items.
I wonder whats going on the database?

I think on db side somethink just like "session" will have opened for every connections to db.

Are they destroyed when connections collected by garbage collector on jdbc side?
I want to know one thing.

What happens if i dont close Connections Statements and Resultsets?

I think garbage collectors will clean them even they are not closed.Because they wont be used and not referenced to anywhere and anymore.

I wonder whats going on the database side?
[ July 04, 2005: Message edited by: rasit fidanov ]
Ok.I think i got it.
Now i must practise.

Thank you very much.

Special thanks to Roger.
Thanks master...
ummm,I wrote a reply for 1-2 hours ago.
However some connection failures prevented me enter new reply.

within this time i read some more about transactions.A Transaction is indiviseable unit jobs.

Hmmm.I think i got it.

if an sql depends to others or you cant do it without them they all must be in same transaction.
(atomic =atom was know as indiviseable in past as you know,i got it.)

hmmm.
But another question occured in my mind.
I thik its important too.

The question is;

assume that we have a transaction, agroup of several sql groups.Some of them selects and some of them inserts,deletes etc...

We know that before commit it doesnt write it to physically to database.
what if we have a milions of rows of a sql query?and

while in transaction and not commited ,another user makes a query and commits to db before we commit?

so then what will happen?We will lose some datas i think...Becouse transacion did not finish and not committed.

I thank you all.Thanks for your helps.
[ July 01, 2005: Message edited by: rasit fidanov ]
thanks for answers,

@Roger Chung-Wee :
you mean when ever i commit an sql query i have to put it in a try catch block or only one try catch block at the end of the querries?

i mean;

try{
conn.setAutoCommit(false); // start of JDBC transaction
delete from x table
conn.commit(); // end of JDBC transaction
}catch(Exception e){
conn.rollback();
}
.
.
.//another commit

try{
conn.setAutoCommit(false); // start of JDBC transaction
update x table
conn.commit(); // end of JDBC transaction
}catch(Exception e){
conn.rollback();
}
.
.
.


or I must do roll back only once at the end of the page in catch of a try catch ?

@Srilakshmi Vara :

Your question is not clear,



sorry.
I am a beginner

Batch?umm i think bacth works like this;
it adds all querries in an order in the statement and sends to database in one when executeBatch() method is invoked..

so i wonder how can i rollback if a problem occured in an sql query which is in the middle of the bacth?

thx for the answers again...

@Roger Chung-Wee :I have heard of it several times ,atomic.
I wonder how can i make my queries atomic or what atomic means in fact?

can you advice me an ebook?or can i demand from you if you have a document.
and if you dont mind
[ July 01, 2005: Message edited by: rasit fidanov ]
Now i have many many statements to execute.some of them are with a ResultSet and somes are not.

I am not sure how to use manually commiting to database.i have found some topics.when i have searched the forum.
They are so simple. so still i am not sure how.

assume that you have in an order of some sql statements like this;

delete from x table

select from x table

insert x table

select x table

insert y table

update y table

select y table

update z table

and on...

I kept it some long for this example.But its just similar to this.

I want to know that do i have to commit after insert delete , update before selection sqls?
Or must i do it only for once in a try catch block at the end of processes?

for example:

Connection conn=DriverManager.createConnection(..);

conn.setAutoCommit(false);

delete from x table
conn.commit();

select from x table

insert x table
conn.commit()

select x table

insert y table

update y table
conn.commit();

select y table

update z table
conn.commit();

And i want to know where to rollback if an exception thrown?

[ June 30, 2005: Message edited by: rasit fidanov ]

[ June 30, 2005: Message edited by: rasit fidanov ]
[ June 30, 2005: Message edited by: rasit fidanov ]