Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

do we have to say connection.commit explicitly after prepared statement execution

Murray9654Jul 28 2015 — edited Jul 28 2015

Hi i am inserting a record using database connection. I am obtaining connection from datasource. After inserting a record using preparedStatement.executeUpdate() do i have to explicitly write connection.commit() ?

This post has been answered by unknown-7404 on Jul 28 2015
Jump to Answer

Comments

gimbal2
Okay, lets filter that story of yours. What you are actually having difficulty with is running a command line utility using Java right? It has nothing to do with GnuPG specifically, so why base your entire question around it? Your thread title will now probably discourage people from coming here because they don't have experience with this tool you're using.

If you want to get help, ask clear questions. That also means drilling down to the core of your problem first.

Your first stop should be reading this article front to back:

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html


Also, read the forum faq to learn how to format the code you post. Right now it is quite a mess.
sabre150
As part of an article I have been writing on the use of Runtime.exec() and ProcessBuilder, for the last couple of weeks I have been writing a simple Java GUI that wraps the 'gpg' command line so I thought I would be able to help here but I don't think I can. You seem to have read some of the 'traps' article and to have implemented some of the recommendations but your exception handling makes your code just about unreadable. If a particular exception means that you have a system error then wrap it in an Error and throw that. If a particular exception means that the caller of your code has provided bad data then throw an exception to tell him that. If you can't think of what to do with an exception then don't do anything; just pass it back to the calling process. Never (well almost never) just smother an exception and just printing a stack trace then continuing is usually wrong.

Note - there is a pretty complete Pure Java PGP library available from BouncyCastle.
876084
thanks sabre 4your aid, you have been able to help me to an extent, let me see if i can do a work around on this because i have been able to implement everything even other processes in the GPG only this part of the creation of the key which if i do that manually using the command line in windows in a batch file it works but during my program it just gives error and just like you said i think i would take your advice and try see if it works well, and would have a look at the bouncy castle if it works like the GPG and every procedure is similar that would save me a lot of problem. thanks very much again.
gimbal2
user13340119 wrote:
thanks sabre 4your aid, you have been able to help me to an extent, let me see if i can do a work around on this because i have been able to implement everything even other processes in the GPG only this part of the creation of the key which if i do that manually using the command line in windows in a batch file it works but during my program it just gives error and just like you said i think i would take your advice and try see if it works well, and would have a look at the bouncy castle if it works like the GPG and every procedure is similar that would save me a lot of problem. thanks very much again.
Just to note: you may need to install the unlimited strength policy into your JRE if you want to use GPG encryption through BouncyCastle to allow encryption keys of any length.

http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html
876084
thanks sabre and gimbal2 for your assistance but i have checked this pgp implementation, i found out it is not open source, and i will love to work with this gnupg version because it is open source. also i found out the process is likely similar in generating keys in pgp but i do not seem to see where this part as specified by this website http://www.gnupg.org/gph/en/manual.html similar to http://www.seas.upenn.edu/cets/answers/pgp_keys.html in terms of the key generation; can be implemented via my application without actually interacting with the command prompt on windows which is my major problem. but i still appreciate your helpful details provided earlier, however, any further assistance would be much appreciated.

Edited by: user13340119 on Jul 20, 2011 6:13 AM
sabre150
user13340119 wrote:
thanks sabre and gimbal2 for your assistance but i have checked this pgp implementation, i found out it is not open source,
If you are referring to the BouncyCastle PGP then it most definitely is open source!
876084
after trying a lot of things i learnt a lot on my way and still come about the solution which is what i have pasted below in my codes, sorry for pasting it late.

thanks for all the assistance from the people that have helped me.

code_tags

//create key
public boolean createkey(String user, String regno, String email, String passphrase){
boolean success=false;
String other="Key-Type: RSA\n"
+ "Key-Length: 2048\n"
+ "Subkey-Type: ELG-E\n"
+ "Subkey-Length: 1024\n"
+ "Name-Real: "+ user+"\n"
+ "Name-Comment: "+regno+"\n"
+ "Name-Email: "+email+"\n"
+ "Expire-Date: 365\n"
+ "Passphrase: "+passphrase+"\n"
+ "%commit\n";
success = runGnuPG ("--gen-key --batch --yes --no-tty",other);
try{Thread.sleep(2000);//wait for operation to complete
}catch(Exception ex){}
if (success && this.gpg_exitCode != 0)
success = false;
return success;
}

code_tags

once again many thanks in advance.

Edited by: user13340119 on Aug 29, 2011 7:00 AM
1 - 7
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 25 2015
Added on Jul 28 2015
7 comments
4,243 views