Use of JTA API in JDBC programs.
Hi,
Where we can use JTA API in JDBC programs. what is the significance of UserTransaction interface in JDBC programs. I heard that when we are using two databases in same program then we use this JTA API. Can't we do this by using,
connection.setAutoCommint(false);
// code to work with two database
connection.commit();
does it wont work.
Please suggest me.
Thanks
Satish
I heard that when we are using two
databases in same program then we use this JTA API.
Can't we do this by using,
connection.setAutoCommint(false);
// code to work with two database
connection.commit();This will work if there are no errors or crashes, but it can seriously fail otherwise.
To find out more: you can download our JTA from http://www.atomikos.com and go through the JTA user guide. It includes the answer to your question.
Alternatively, feel free to check our transactions community forum on http://www.atomikos-support.com/forums (which we check more often than this one).
Best,
Guy
Similar Messages
-
Can i use Access 2000 for my JDBC program?
I tried to run a JDBC program from a book and it worked. The problem is, it uses an outdated "Informix" database. I want to do it in Access 2000. Is it possible?
Please give me a sample code if you have guys.
Thanks
MosesYou have to create a DSN (Data Source Name) in Windows first. You name that DSN, and that name is what you use in your url (url = db connection string).
Say you have Students.mdb.
You create a DSN that points to that file and name it "studentdb", or whatever name you like (do this from the odbc data sources item in the windows Control Panel).
You format your url in the format "jdbc:odbc:<DSN name>". IN this case, your dsn name is "studentdb", so the url would be "jdbc:odbc:studentdb". You were supposed to replace "myAccessDSN" with the name of your newly created DSN.
The other two arguments are for username and password, which typically aren't needed for Access dbs.
So in the end you execute the following:
Connection con = DriverManager.getConnection("jdbc:odbc:studentdb","",""); -
How can we use Essbase grid API for VB
Hi Experts
I am developing a custom application to talk to Essbase in VB6 environment.
I need to retrieve data from the essbase. When i am using EsbReport to execute the report script query, it takes a lot of time to parse through the returned output and even sometimes, the application prompts "Out of Memory" error.
1. Is there any faster way to extract data from Essbase using VB APIs
2. I was going through Grid APIs which gives the ability to extract data from Essbase in Grid format in a comparatively faster manner. Do we have any such Grid APIs for VB? or is there any way to use C grid APIs in VB program?
Please help :(Hi,
Its hard to say if there is a faster way without knowing how you're doing it now. A few questions:
- why are you using the API to get at Essbase Data, especially if you've already defined a (some) report scripts?
- if you want to use provider services, vs having to ensure all the libraries and the client are present, why not use the JAPI?
- Without seeing your code, its hard to know why you're getting out of memory errors. What are you doing with the data as you're parsing it from the report?
Grid API exists for the C API, and more noteable the JAPI, but not VB(I'm surprised the VB api still exists).
Why not just use the Java API?
Robb -
How to use oracle collection type with JDBC?
I try to use oracle collection type in java program. So I made some package and java program, however Java program was not found "package.collectiontype"(JDBC_ERP_IF_TEST.NUM_ARRAY) . please, show me how to use this.
Java Version : Java 1.4
JDBC Driver : Oracle Oci Driver
DB: Oracle 9i
No 1. Package
===========================================
create or replace package JDBC_ERP_IF_TEST AS
type NUM_ARRAY is table of number;
procedure JDBC_ERP_IF_ARRAY_TEST(P_NUM_ARRAY IN NUM_ARRAY, ERR_NO OUT NUMBER, ERR_TEXT OUT VARCHAR2);
procedure TEST(ABC IN NUMBER);
END JDBC_ERP_IF_TEST;
==================================================
No 2. Package Body
===============================================
CREATE OR REPLACE package BODY JDBC_ERP_IF_TEST is
procedure JDBC_ERP_IF_ARRAY_TEST(p_num_array IN NUM_ARRAY,
ERR_NO OUT NUMBER,
ERR_TEXT OUT VARCHAR2) is
begin
ERR_NO := 0;
ERR_TEXT := '';
dbms_output.enable;
for i in 1 .. p_num_array.count() loop
dbms_output.put_line(p_num_array(i));
insert into emp (empno) values (p_num_array(i));
commit;
end loop;
EXCEPTION
WHEN OTHERS THEN
ERR_NO := SQLCODE;
ERR_TEXT := ERR_TEXT ||
' IN JDBC INTERFACE TEST FOR ORACLE ERP OPEN API..';
ROLLBACK;
RETURN;
end JDBC_ERP_IF_ARRAY_TEST;
procedure TEST(ABC IN NUMBER) IS
begin
insert into emp(empno) values (ABC);
commit;
end TEST;
end JDBC_ERP_IF_TEST;
===============================================
NO 3. Java Program
===============================================
ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("JDBC_ERP_IF_TEST.NUM_ARRAY", getConnection());
ARRAY array = new ARRAY(descriptor, getConnection(), arrs);
cstmt = getConnection().prepareCall(LQueryFactory.getInstance().get("Meta/Basic/testJdbcErpArrayIf").getSql());
cstmt.setArray(1, array);
cstmt.registerOutParameter(2, Types.INTEGER);
cstmt.registerOutParameter(3, Types.VARCHAR);
====================================================
couldn't find this phase => JDBC_ERP_IF_TEST.NUM_ARRAY
what can i do for this package and program? please help me..Something like this:
create or replace type t_record as object (
id number,
no number
CREATE or replace type t_table AS TABLE OF t_record;
set serveroutput on
declare
v_table t_table := t_table();
v_t1 t_table := t_table();
begin
v_table.extend(1);
v_table(1).ID := 1;
v_table(1).No := 10;
v_table.extend(1);
v_table(2).ID := 2;
v_table(2).ID := 20;
SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
from TableA
FROM TABLEA
WHERE ID IN (select t.ID from table(v_Table) t);
for i in 1..v_t1.count loop
dbms_output.put_line(v_t1(i).ID);
dbms_output.put_line(v_t1(i).No);
end loop;
end;
/Untested!
P;
Edited by: bluefrog on Mar 5, 2010 5:08 PM -
How do i use java printing api 1.4
How can i print documents using jdk1.4 api.
I have used the following program for printing.
import java.io.*;
import java.awt.*;
import java.awt.print.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
public class Print2DtoStream implements Printable{
public Print2DtoStream() {
/* Use the pre-defined flavor for a Printable from an InputStream */
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
/* Specify the type of the output stream */
String psMimeType = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();
/* Locate factory which can export a GIF image stream as Postscript */
StreamPrintServiceFactory[] factories =
StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, psMimeType);
if (factories.length == 0) {
System.err.println("No suitable factories");
System.exit(0);
try {
/* Create a file for the exported postscript */
FileOutputStream fos = new FileOutputStream("out.ps");
/* Create a Stream printer for Postscript */
StreamPrintService sps = factories[0].getPrintService(fos);
/* Create and call a Print Job */
DocPrintJob pj = sps.createPrintJob();
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
Doc doc = new SimpleDoc(this, flavor, null);
pj.print(doc, aset);
fos.close();
} catch (PrintException pe) {
System.err.println(pe);
} catch (IOException ie) {
System.err.println(ie);
public int print(Graphics g,PageFormat pf,int pageIndex) {
if (pageIndex == 0) {
Graphics2D g2d= (Graphics2D)g;
g2d.translate(pf.getImageableX(), pf.getImageableY());
g2d.setColor(Color.black);
g2d.drawString("example string", 250, 250);
g2d.fillRect(0, 0, 200, 200);
return Printable.PAGE_EXISTS;
} else {
return Printable.NO_SUCH_PAGE;
public static void main(String args[]) {
Print2DtoStream sp = new Print2DtoStream();
However when i run this program,it prints "example string" as used in g2d.drawString("example string",250,250) method above.
What if i want to print content from any file.
So anybody konwing this plz replyThis is covered pretty well in the Java Print Service API Guide.
You could start here http://java.sun.com/j2se/1.4.1/docs/guide/jps/spec/printing.fm1.html
Basically, you have two choices - either you're going to throw a document at the print service, or you're going to print using Graphics2D commands. You also have the choice between printing to a printer, or to a stream. Mix and match for four combinations.
Whether you can just take a raw document and send it to a printer via the document printing stuff depends on what print services you have installed. For the standard J2SE, it's pretty limited.
If you're doing it via the Graphics2D approach, however, you can print anything you can draw. That's nice - it means you can use the same code to display stuff on the screen and print it. -
How to start JDBC program from web.
Okay I have researched this alot on how you are suppose to connect to a database using JSP and all the example just show how to print the entire database. What I need to do is take a JDBC program I have written and make it run on a web page. How can I call the program to run on a web page. The JDBC program will search,update,add information into a database but how do I get the JDBC program run on a web server. I am a newbie in JSP.
Then could someone tell me what is the point in learning JDBC if you can't use it for web applications? Could someone then tell me which to learn in order for me to implement using my database on the web. Should I learn how to do it as a servlet or in JSP. Which is going to require less time to learn. I am kinda in a time crunch on this one. I would really like to learn both and I will probably go back and do that but I don't have time to learn both so any advice would be helpful. Thank you for you time.
-
How to use shared variables with native c programs
Hello
What is the way to use shared variables with native c programs?
I have a c/c++ program that uses the NIDAQmx C-API to perform measurements. Now I want to communicate to a LabVIEW program via shared variables.
Is there a C-API for shared variables as there is for the NIDAQmx functionality? Where can I find further documentation? The document "Using the LabVIEW Shared Variable" mentions that one "can read and write to shared variables in ANSI C", but there are no hints about how and where to look.
Thanks in AdvanceHi user42,
with CVI 8.0, you cannot create or configure shared variables. However, you can read or write to an already configured LabVIEW 8.x shared variable from CVI using the DataSocket API.
In order to do this you need to have and DataSocket 4.3 or higher installed.
Here's a forum post about using the DataSocket functions a LabVIEW Shared Variables:
http://forums.ni.com/ni/board/message?board.id=180&message.id=24569&requireLogin=False
With CVI 8.1 and Measurement Studio 8.1 it's possible to use Shared Variables via the Network Varaiable Library (check out the end of the "Network-Published Shared Variable" section within the "Using the LabVIEW Shared Variable" documentation and the following link).
Datasocket with LabWindows/CVI and LabVIEW Real-Time:
http://digital.ni.com/public.nsf/allkb/CC4343488413A2F586256E6200099638?OpenDocument
Daniel
NIG -
Suppressing Applet alerts when using java mail api
Hi,
Im using the following code to send email from my application. Im using JSF (tomahawk), Spring and hibernate in my application. I'm using spring email API classes to send email. This code works perfectly fine in the sense its parsing template and sending emails to the configured email id.
I have defined this class as a managed bean and i have a commanButton is UI which is bound to this sendEmail() method
<t:commandButton value="Send email" action= #{email.sendEmail}/>
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.runtime.resource.loader.StringResourceLoader;
import org.apache.velocity.runtime.resource.util.StringResourceRepository;
import org.springframework.mail.MailException;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.mail.javamail.MimeMessageHelper;
import au.gov.nsw.railcorp.onlineticketing.external.model.request.ServiceFees;
public class EmailService {
JavaMailSenderImpl sender;
VelocityEngine engine;
public EmailService(){
sender = new JavaMailSenderImpl();
sender.setHost("<smtp ip>");
sender.setPort(25);
sender.setUsername("<user id>");
sender.setPassword("<password>");
engine = new VelocityEngine();
Properties p = new Properties();
p.setProperty("resource.loader", "string");
p.setProperty("string.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.StringResourceLoader");
try {
engine.init(p);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
public VelocityEngine getEngine() {
return engine;
public void setEngine(VelocityEngine engine) {
this.engine = engine;
public JavaMailSenderImpl getSender() {
return sender;
public void setSender(JavaMailSenderImpl sender) {
this.sender = sender;
public static void main(String args[]){
EmailService emailService=new EmailService();
emailService.sendEmail();
public boolean sendEmail(){
try{
MimeMessage message = sender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message);
helper.setTo("<to email id>");
helper.setFrom("<from email id>");
helper.setSubject("Teting velocity");
VelocityContext context = new VelocityContext();
StringWriter writer = new StringWriter();
Template template =new Template();
StringResourceRepository repository =StringResourceLoader.getRepository();
String tempText="<html><body>Hi, ${username}...<p> this is a some template!</p></body></html>";
repository.putStringResource("myTemplate",tempText );
context.put("username", "Marc");
template = engine.getTemplate("myTemplate");
template.merge(context, writer);
System.out.println("VM Template:\n" + tempText);
System.out.println("Output:\n" + writer);
String body=writer.toString();
helper.setText(body,true);
sender.send(message);
catch (MessagingException ex) {
// simply log it and go on...
System.err.println(ex.getMessage());
catch (MailException ex) {
// simply log it and go on...
System.err.println(ex.getMessage());
} catch (ParseErrorException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return true;
}The problem i have is when i try to invoke the function sendEmail() from my UI it is throwing a series of applet alerts (some 10 of them) . The following are the alerts that i get
1. The applet is attempting to invoke the java/lang/System.getProperty() operation on java.home
2. The applet is attempting to perform a read operation on the file C:\Program Files\java\jre1.5.0_14\javamail.providers
3. The applet is attempting to perform a read operation on the file C:\Program Files\java\jre1.5.0_14\javamail.address.map etc....
For ever applet alert i had to click on 'allow' for it to proceed. But there is no problem in sending mail after that. One more interesting this is i DONT get this alert when i try to execute this java class directly instead of calling the method from another class or from UI.
Can someone please let me know the reason for this applet alert and the way to suppress it?
Its really urgent .. please help
Thank you..Hi Subhadip,
Thanks for the quick response :)
Please help me understand this.. Im not explicitly using applet anywhere .I guess it should be used internally by one or many of the API classes i have used . In this scenario how can self sign the applet and which one?
I have included some jars like activation.jar,mail-1.4.2.jar,velocity-1.6.2.jar in my webapp lib . Is there a means to sign these jars and use? Is this what you are suggesting me to do?
One more doubt i have is how come the same method runs without any problem when executed as a standalone java class (with main() method)
Will be really helpful if you could help me understand this...
Thanks,
Swami -
I am trying to use fnd_webattch.add_attachment API to attach document to an invoice.
But the program seems successfully loaded the attachment to Invoice. But when I try to open the attachment from UI, I got ORA-01403 no data found screen.
Don’t know what’s worng with code, Can someone help?
My pdf file is locate at app and DB servers.
Here is my sql program,
set feedback off
set verify off
set serveroutput on size 100000
set autocommit off
Declare
v_category_id NUMBER;
v_attached_doc_id NUMBER;
v_invoice_id NUMBER :=2814131;
v_invoice_image_url VARCHAR2(500) := NULL;
v_function_name VARCHAR2(50) := 'APXINWKB';
v_category_name VARCHAR2(100) := 'CUSTOM291';
v_description VARCHAR2(300) := 'Test script for attaching OB10 scanned image file to AP invoice';
v_entity_name VARCHAR2(100) := 'AP_INVOICES';
v_file_name VARCHAR2(100) := '/tmp/AMKOR_PRD_0000577922_20130712-151504.pdf';
v_user_id NUMBER := 1234;
TYPE result_set_type IS REF CURSOR;
v_result_set_curr result_set_type;
CURSOR cur_cat_id
IS
SELECT fdc.category_id
FROM fnd_document_categories fdc
WHERE fdc.name = v_category_name;
BEGIN
OPEN cur_cat_id;
FETCH cur_cat_id INTO v_category_id;
CLOSE cur_cat_id;
-- Invoke the fnd_webattach api for attaching the file to the invoice
fnd_webattch.add_attachment ( seq_num => 100
,category_id => v_category_id
,document_description => v_description
,datatype_id => 6
,text => NULL
,file_name => v_file_name
,url => v_invoice_image_url
,function_name => v_function_name
,entity_name => v_entity_name
,pk1_value => v_invoice_id
,pk2_value => NULL
,pk3_value => NULL
,pk4_value => NULL
,pk5_value => NULL
,media_id => NULL
,user_id => v_user_id
,usage_type => 'O'
SELECT count(fad.attached_document_id)
INTO v_attached_doc_id
FROM fnd_attached_documents fad
WHERE fad.pk1_value = v_invoice_id;
IF v_attached_doc_id > 0
THEN
DBMS_OUTPUT.PUT_LINE('Attached sucessfully');
ELSE
DBMS_OUTPUT.PUT_LINE('Failed to Link the Attacment.');
END IF; --IF v_attached_doc_id > 0Hi Hussein,
Yes. I got "Attached Successfully" message at the end.
Don't know why it didn't created FND_LOBS record for it.
My sql was copied from the reference on your reply.
Thanks,
Florence -
Can't see my tables from a JDBC program
Hi there,
I have a JDBC program to connect to an Oracle 9i database. The problem is that I can't see the tables I create if I do something like "SELECT * FROM TAB" from a JDBC program and hence can't use them.
If I do the same statement from SQL * PLUS, I get the the full list of my tables including the ones I created. If i do that from JDBCTest.java, I don't get to see them. I do commit my statments and have tried committing from the Java program and from the SQL Plus after creating the tables....
Just to make sure I have checked myself, I am pretty sure that I am connecting with the same ID/Password in which I created my tables. I have also used schema.table to no avail... I have used scott/tiger and system/manager
If i try st.executeUpdate() for example, I get the error : java.sql.sqlException: ORA-00942: table or view does not exist...
Any help would be greatly appreciated
Thanx :)
NavHi MOD,
hmmm. Sorry I am not an Oracle geek, but I am under system/manager and I created them all in there. I thought permissions are granted automatically. I tried to grant permissions to myself but had an error that I can't update them myself...
Can you plz elaborate on how to set permissions cuz actually i installed the database (password still default) and I am not sure if there is a dba other than system/manager who could grant me permissions...
It works on my home machine with the exact same version of Oracle and Java though and the same users and password :s
Any other thoughts
Thanx
NAV -
JNI FindClass Error: Using the Invocation API from visual C++
I am using JNI invocation api in microsoft visual c++ to invoke java. When I use the FindClass method, I get a return value of 0. I have verified that the class "a" exists and believe have set the java class path appropriately. A valid jvm and jenv are created. The program fails at the FindClass call and returns 0.
std::string classPath = "c:\\work\\java;C:\\j2sdk1.4.2_08;C:\\j2sdk1.4.2_08\\bin;C:\\j2sdk1.4.2_08\\lib";
vmArgs.classpath = classpath;
jint res = JNI_CreateJavaVM(&jvm, (void**)(&jenv), &vmArgs);
if (res < 0)
cout << "Error!! Cannot create jvm" << endl;
jclass jFixEngineClass1 = jenv->FindClass("a");
if (jFixEngineClass1 == 0)
cout << "Error could not find a class" << endl;
else
cout << "a class found" << endl;
thanks in advance,
hcgJschell,
Thanks for your help.
I found the error. I was using JDK1_1InitArgs for my vm_args. Since, I am using JDK 1.4, the classpath I was setting was not getting picked up. I changed the vm_args type as in the code below and it worked.
JavaVMInitArgs vmArgs;
JavaVMOption options[1];
char classPathDef[1024];classPathDef[0] = '\0';
sprintf(classPathDef, "%s", "-Djava.class.path=");
sprintf(classpath, "%s%s", classPathDef, NYSE_FIX::userClassPath.c_str());
options[0].optionString = classpath;
cout << "Option string is:" << options[0].optionString << endl;
vmArgs.version = 0x00010004;
vmArgs.options = options;
vmArgs.nOptions = 1;
vmArgs.ignoreUnrecognized = JNI_TRUE;
jint ret = JNI_GetDefaultJavaVMInitArgs(&vmArgs); -
How can I get the language of the user logged on using only DI API?
Hello,
how can I get the language of the user logged on using only DI API,
without invoking the UI?
Can I read the value from some table using sql?
I could write to file the first user's connection to the language code in SAP and then use it from external program, but I do not like this solution ...
I know only this possibility:
'_SboCy ==> SAPbobsCOM.Company
'_SboCys ==> SAPbobsCOM.CompanyService
'_SboApp ==> SAPbouiCOM.Application
CodLng Dim As String = ""
Dim lng As SAPbobsCOM.UserLanguages _SboCy.GetBusinessObject = (BoObjectTypes.oUserLanguages)
If lng.GetByKey (_SboApp.Language) Then
codLng = lng.LanguageShortName
'Etc. ..
End If
lng = Nothing
ThanksHi Enrico,
The language settings are held on the user's Windows profile and not in the database. In SBO 2007A onwards there is an XML file that is created by the SBO client (previous versions stored the information in the registry). The file is called b1-current-user.xml and you'll find it in the temporary application data under the user's profile (by default this will be C:\Documents and Settings\<profile>\Local Settings\Application Data\SAP\SAP Business One for Windows XP). This XML file contains a node that looks like the following:
<leaf kind="single" name="Language" type="String">
<value>8</value>
</leaf>
where the value is the language id that should correspond to the same setting in the DI API. If your application will always run on a workstation where the SBO client is installed then you could read this XML file. Of course, this file may not exist for a particular Windows user if they have never opened the SBO client so you'd need to have a default setting.
If you application will be installed on a workstation which doesn't have an SBO client installed on it then there is no way to tell what default language to use and you'll need to build this logic in to your own application (eg have a screen where the user can choose their preferred langauge and then store this as a config file in a similar way to how the SBO client works).
Kind Regards,
Owen -
Creating junit test cases using the reflection API
In order to use the reflection API to get information about a *.java file's class name and methods, I need to compile the *.java file first, and then get info through the *.class file. Am I right?
Eclipse, the Java IDE, can create junit test cases for java files the user selects right after the *.java files have been created, and even before the *.java files have been compiled by the user. I guess Eclipse internally compiles the java files before creating JUnit test cases for them. Does anyone know about it? Thanks.Let me explain my problem in more details.
Given any java source tree, my program is supposed to create junit test cases for each class using java reflection. My approach is to scan through the source tree to keep the list of classes available, then compile all the java files in the given source tree, then do Class.forName() to load them to get their methods... Obviously I don't know what classes I will have at compilation time. I create a temp_classes directory as the output directory for the given source tree java files, and I add temp_classes to my classpath when I strart up my own program. However, that won't work..
D:\eclipse\workspace\cmpe271_hw4\classes>java -classpath ..\classes;..\temp_classes Test
javac -classpath .\temp_classes; -d .\temp_classes @temp_classes\javalist.txt
java.lang.ClassNotFoundException: Factory
java.lang.ClassNotFoundException: InvalidDateFormatException
java.lang.ClassNotFoundException: MyUtility
java.lang.ClassNotFoundException: Storage -
I am about to build a small J2SE Gui app but think I need to build in some Transactional features
Can I use JTS/JTA outside of an AppServer environment - if so can your provide some pointers/docs/links
for example in the JINI world there is a Transaction Management service (Mahalo) - is this really just JTA/JTS repackaged for the JINI worldI'm not sure that just a JDBC Transaction wil sufficeI believe it's sufficient.
I had in mind manipulating several classes worth of data via a GUIThe fact that you're doing it with a GUI is immaterial.
If all goes well I can commit/update the underlying
DB - otherwise I need to 'Rolback' the changes
(potentially inside the DB & also in the GUI
supporting classes)If you have good MVC separation it's not a problem.
Sounds like you'll need to write your DAO persistence layer in such a way that several objects can participate in a transaction. No problem - do it in such a way that you pass a shared Connection between all the objects. Set auto commit to false for the Connection before you start, and then follow the usual idiom.
If you commit, update the VO in the middle tier and ask the GUI to display them.
If you rollback, the middle tier VO are unchanged and the GUI ends up displaying the original values again.
% -
How to hide username/password in JDBC program.
hi All,
The support tat I get here is simply gr8.
Can someone suggest or send me a link as to how I hide the username /password ....i.e database connection in the jdbc program so as to avoid changing the program everywhere in case username and passwd changes ?????
I simply want to change the following code
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName).newInstance();
// Create a connection to the database
Sring serverName = "127.0.0.1";
String portNumber = "1521";
String sid = "oratest";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "scott";
String password = "tiger";
connection = DriverManager.getConnection(url, username, password);
Ta,
sunnywell i kind of support what my fellow poster neeelima.srtidhar said..
Use of Connection Pooling via JNDI which is either provided by appln server or using custom built frameworks is the best method which i can think of instead of reinventing the wheel by creating a Properties file and then writing a Utility Class which ultimately endup in creating connection Object without any sort of optimal usage.
checkout the below articles for reference of how to do it.
http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html
http://www.informit.com/articles/article.asp?p=352320&rl=1
http://www.codeproject.com/useritems/pool_client_jboss.asp
http://edocs.bea.com/wls/docs81/jdbc/programming.html
http://www.castor.org/jdo-pooling.html
http://homepages.nildram.co.uk/~slink/java/DBPool/
and if you are thinking of reinventing those that could be possible using the below article
http://www.javaworld.com/javaworld/jw-05-2002/jw-0517-jdbcdriver.html?page=1
Hope that might help:)
REGARDS,
RaHuL
Maybe you are looking for
-
HT4623 How do I find my emei number in iTunes when I've lost my phone
How do I find my emei number in iTunes when I've lost my phone
-
New order type for a purchase order similar tu UB.
Hi, I would like to know if it is possible to create a new order type for a purchase order. This new order type should work as a UB order type but "plant" and "storage location" should be indicated by default and shouldn't be changed. How should I pr
-
Image scaling problem with object handles
Hi, I am facing scaling problem.I am using custom actionscript component called editImage.EditImage consists imageHolder a flexsprite which holds image.Edit Image component is uing object handles to resize the image.I am applying mask to the base ima
-
Urgent help pls: certificate based authenticaion
Hi Experts, I am new this concept of SSL. I have a ejb sitting in a weblogic. I dont have user based authentication. But only from certain hosts, my ejb should be accessible. I read lot of theoires about certificate, keystore, CA etc. But can any one
-
Will there be an Ergotron MX Desk Mount arm for the IPAD 2?
Having trouble finding a functional AND attractive clamping desk mount for a drafting table (which sits at an incline). The Ergotron is pefect but only made for computer monitors. After having researched this for a couple of weeks, Im here to tell yo