How to use two different database Drivers in one application ????

I want to select datas in a result set of a query on a ms access database table and insert these into a mysql table of a mysql database in one application.
Now my problem is that only on database driver is acceptet in the same application even it`s instanciatet in a completely different class !!!
Here's the structure of my program:
class one:
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
database += filename.trim() + ";DriverID=22;READONLY=false}";
java.sql.Driver driver0=new sun.jdbc.odbc.JdbcOdbcDriver();
DriverManager.registerDriver(driver0);
DriverManager.getDriver(database);
con2=DriverManager.getConnection(database,"","");
DatabaseMetaData dmd2;
dmd2=con2.getMetaData();
stmt2=con2.createStatement();
rs2=("SELECT (.........
until here all values can be selected correctly from ms access
class2.get_gas_id(fla_gas);
Now I want to insert these values into mysql.
By despair i created a second class with another jdbc-method:
class2:
public class gas_select{
public static int fla_gas_id;
public static void get_gas_id(String fla_gas)
java.sql.Statement stmt3;
java.sql.Connection con3;
java.sql.ResultSet rs3;
FileWriter fout1;
try
java.sql.Driver driver1=new org.gjt.mm.mysql.Driver();
DriverManager.registerDriver(driver1);
DriverManager.getDriver(config.db_rge_stoffe); ==>
config.rge_stoffe="jdbc:mysql://192.168.10.101:3306/rge_stoffe?user=<user>";
con3=DriverManager.getConnection(config.db_rge_stoffe);
java.sql.DatabaseMetaData dmd3;
dmd3=con3.getMetaData();
stmt3=con3.createStatement();
rs3=stmt3.executeQuery("SELECT (Nr) from tblgaseliste where Gasart like "+"\'"+fla_gas+"\'");
while(rs3.next())
fla_gas_id=rs3.getInt("Nr");
fout1.write(fla_gas_id);
stmt3.close();
con3.close();
fout1.close();
There's no result and no error message. Idon't know what to do !
Has anyone an idea ???
Edited by: goberger on Mar 27, 2008 3:35 PM

Hi!
If I understand your problem correctly, you can create connections to as many databases as you want in one class. In one of my programs I have connection to 3 separate databases, but here is an example:
Connection mysql_con = DriverManager.getConnection("jdbc:mysql://localhost:3306/dbmysql", "root", "12345");
Connection pg_con    = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5433/dbpgsql", "postgres", "12345");Then from mysql_con and pg_con create PreparedStatement or Statement then load selections into ResultSet and then use getString() to get a basic String type result that you want and so update table from each database.
HTH
Victor.
BTW Here I use port 5433 for PostgreSQL connection because I SSH tunnel it from 5432 to 5433
Edited by: vic_sk on Mar 27, 2008 4:23 PM

Similar Messages

  • How to use two different network cards on RT?

    Hi everyone... I'm currently working on a project where I have to deal with the issue mentioned in the thread's topic: I have a PC with RT LabVIEW that has to be able to establish network connections using two different network cards. One will be used to connect via TCP/IP with a host computer that will show the data transmitted through shared variables; the other will communicate with another PC through Modbus protocol. The key is that each communication is done through a separate network card.
    So far I haven't been able to figure out how to configure both things to happen. Does anyone know how to do this? Any tips will help.
    For the RT communication I'm using a standard RT project, with the RT PC being given one of the IPs, and for the Modbus part, I created an I/O server with a master and a slave. Separately everything works fine, but when I get them together it simply won't work.
    Thanks for your help!
    Solved!
    Go to Solution.

    Sorry it took me so long to answer, I've been busy lately....I've found a solution to the problem I mentioned, and just in case anyone has similar problems in the future, I'll shortly describe what happened.
    As Caseyw suggested, it was necessary to enable both network cards through the Measurement and Automation Explorer. The cause of the connections malfunction was actually that I wasn't using the "right" protocol for the Modbus communication, which ran on the secondary adapter. The solution was to use the URL protocol with the correct path on the field, addressing the right IP address. To avoid making this post a mixture of topics, I won't elaborate futher, but I got the gist of it, so if anyone is having similar problems whether it is working with several network cards or with Modbus communication protocols, feel free to contact me, I'll be glad to help.
    Thanks

  • How do I use two different apple IDs on one itunes?

    How do I use two different apple IDs on one itunes?

    This would be a violation of the terms of use of the itunes store and could result in the loss of your account.
    You cannot use the U.K. itunes store unless you are in the U.K

  • Can I use two different database with DBSystemLoginModule?

    Finally I can login with Database user id by DBSystemLoginModule on Embedded oc4j server.
    But I confused between [b]jazn-data.xml and system-jazn-data.xml.
    Which xml do I have to edit for jdbcUrl and jdbcDriver?
    Now I would like to use two different database(such as only sid is different).
    In this case I want to show specific database name as realm name.
    What should I do?
    When I use DBSystemLoginModule, I edit JdbcUrl in system-jazn-data.xml.
    So can I pass the parameter for sid programmatically?
    And also I tried to run my application with other database with DBSystemLoginModule on Embedded oc4j server.
    I changed few things(jdbcUrl at system-jazn-data.xml,jazn-data.xml in embedded-oc4j-server/config and database connection for BusinessComponents at Project Properties of Model/ViewController.
    But I got some error.
    Did I miss something?
    ----< my error messgae >------
    500 Internal Server Error
    JBO-30003: The application pool (customer.model.datamodel.CMAppModuleLocal) failed to checkout an application module due to the following exception:oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.lang.NullPointerException, msg=null     at oracle.jbo.common.ampool.ApplicationPoolImpl.doCheckout(ApplicationPoolImpl.java:2002)     Message was edited by:
    Message was edited by:
    sdcsdc

    I think I understand now, you are modifing the custom login modules configuration within the system-jazn-data.xml file. This is a bit dangerous! Didn't you register the login module in your orion-application.xml? For example, this is the way I do it:
    <web-module id="customProv-web" path="customProv-web.war" />
    <persistence path="persistence" />
    <!--data-sources path="./data-sources.xml"/-->
    <security-role-mapping name="sr_developer">
    <group name="developers" />
    </security-role-mapping>
    <security-role-mapping name="sr_manager">
    <group name="managers" />
    </security-role-mapping>
    <jazn provider="XML">
    <property name="custom.loginmodule.provider" value="true"/>
    <property name="role.mapping.dynamic" value="true"/>
    <property name="role.compare.ignorecase" value="true"/>
    </jazn>
    <!-- Configuring a Login Module in an Application EAR file. -->
    <jazn-loginconfig>
    <application>
    <name>customProv</name>
    <login-modules>
    <login-module>
    <class>oracle.security.jazn.login.module.db.DBTableOraDataSourceLoginModule</class>
    <control-flag>required</control-flag>
    <options>
    <option>
    <name>data_source_name</name>
    <value>jdbc/OracleDS2</value>
    </option>
    <option>
    <name>roles_fk_column</name>
    <value>userName</value>
    </option>
    <option>
    <name>table</name>
    <value>userinfo</value>
    </option>
    <option>
    <name>groupMembershipTableName</name>
    <value>groupinfo</value>
    </option>
    <option>
    <name>groupMembershipGroupFieldName</name>
    <value>role</value>
    </option>
    <option>
    <name>usernameField</name>
    <value>userName</value>
    </option>
    <option>
    <name>user_pk_column</name>
    <value>username</value>
    </option>
    <option>
    <name>passwordField</name>
    <value>passWord</value>
    </option>
    </options>
    </login-module>
    </login-modules>
    </application>
    </jazn-loginconfig>
    <log>
    <file path="application.log" />
    </log>
    <namespace-access>
    <read-access>
    <namespace-resource root="">
    <security-role-mapping name="<jndi-user-role>">
    <group name="administrators" />
    </security-role-mapping>
    </namespace-resource>
    </read-access>
    <write-access>
    <namespace-resource root="">
    <security-role-mapping name="<jndi-user-role>">
    <group name="administrators" />
    </security-role-mapping>
    </namespace-resource>
    </write-access>
    </namespace-access>
    </orion-application>

  • Can I use two different itune accounts on one computer?

    Can I use two different itune accounts on one computer?

    1. Give her a separate user account on your computer. If you have a backup copy of the library, you can restore it.
    2. If you encounter a 90-day waiting period, click here and ask the iTunes Store staff if they'll remove it.
    (125941)

  • How to add two different database connections on Model

    Hi,
    In my application, I need to create View Objects on different databases. So I need to add two different database connections on the Model.
    But it seems like Model can be connected to only one database. I tried adding another project to add the second db connection. But after I created a read-only View Object in the second project, it didn't generate corresponding data control in the Data Controls panel.
    Could anyone help me on this?
    Thanks!

    Do you mean adding the second project folder in ViewController->Project Properties->Libraries and Classpath?Yes, either that or: ViewController -> Project Properties -> Dependencies
    And I didn't see the first Model project in the ViewController classpath. Otherwise it wouldn't work. The first model project IS in 'classpath'. Here's how:
    ViewController -> Project Properties -> Dependencies
    I tried this and recreated the View Object. Still didn't generate the datacontrol. No idea why you had to recreate the VO.
    Is your VO in an application module inside the SECOND project?
    After you are sure that everything is in the ViewController's classpath, just try restarting JDeveloper.
    This is very basic. has to work.

  • How to use two different versions of Firefox at the same time on Snow Leopard?

    I recently upgraded to Firefox 4.0 on my 27" iMac running Snow Leopard 10.6.7.
    Previously, I was using Google's "Page Speed" along with Firebug in Firefox 3.6.15 to optimize images in my web pages, and to find other areas to optimize.
    Page Speed is not yet compatible with Firefox 4.0. I wrote to Google about this some time ago -- no answer yet.
    If I run Firefox 3.6.15 in order to use Page Speed, I run into a few problems afterward when I start using Firefox 4.0 again, since they both use the same "Firefox" folder in my "Application Support" folder.
    How can I set it up so that I can have two separate "Firefox" folders in my "Application Support" folder?
    Or is there an easier way to use two different versions of Firefox simultaneously, even if one has extensions and/or plug-ins installed which are not compatible with the other version?
    Thanks for a great browser!

    Please disregard my question. I just conducted more web search and learned how to use Firefox's profile manager in order to make a separate profile for Firefox 3.6.15.
    You can find instructions on this page:
    http://support.mozilla.com/en-US/kb/Managing%20profiles#os=mac&browser=fx35
    '''A small tip:'''
    If your Firefox app is named anything other than "Firefox" -- say for example "Firefox 3.6.15" -- when you follow the instructions at the above link, make sure you escape the blank space that is before the version number by adding a backward slash before it, when you type the command string in the Terminal. In other words, in that string, you should use this:
    Firefox\ 3.6.15
    I hope that helps someone.
    WW

  • SBO - How to use two different Stock Account within the same Item Group

    Hi,
    I'm currently stuck within one of my implementation.
    I'm deploying the same solution worldwide which worked pretty well until now. All the items are connected to an item group, with a unique GL account, supposed to book at the same time the good receipt and the good issue (Balance-Sheet Account = 14xxxxx).
    My new unit is willing to use two different GL accounts when performing its stock entry (let say 14xxx10) and another GL account for the good issue, let say 14xxx20.
    Do you have any clue so i can please them and keep using at the same time the item group ?
    Thanking you in advance
    Stephane

    Hi,
    In fact, we use the GL account as the HQ Account (Reporting Account) while the "Export Code" will be used to store the local GL Account (greek account).
    As such, we can, somehow handle two different chart of accounts.
    In my reporting, i'm only using a single GL account for stock movements, while my greek counterparts want to handle two different accounts.
    Threfore, i have only two solution since there is normally a one to one relationship between a HQ account and a local account that are :
    1 - Duplicate the HQ accounts
    In that case, i do respect anytime the one to one relationship. I've got one HQ account for one local account. But how can i put this since i can only handle one single stock account.
    2 - I keep my single stock account like this but i won't be managing the possibility to get two different Export Codes.
    Regards
    Stephane

  • Use two different printer services in one web template?

    Hi!
    Is it possible to use two different help services for printing in the same web template (for the same table item)?
    Print1:
    <param name="HELP_SERVICE" value="HELP_SERVICE_PRINT"/>
    <param name="HELP_SERVICE_CLASS" value="ZCL_RSR_XLS_HELP_WINDOW_PRINT"/>
    Print 2:
    <param name="HELP_SERVICE" value="ZPRINTING"/>
    <param name="HELP_SERVICE_CLASS" value="ZBW_PRINT_HELP_SERVICE"/>
    I was thinking that you maybe could change the param name values for the "Help_service" and the "help_service_class" at runtime using the properties for the table item, so that you could choose which one to use, but I havne't been able to do that so far.
    Does anyone have an idea?

    This is not a problem. Just put the print service for the print to excel on an object other than the table web item. As long as these print services exist on any web item, you should be able to invoke them. I've tested this with putting the "Print with Excel" service on the Navigation Block Web Item and the other print service on the table web item. Hope that helps!
    Prakash

  • Use two different I pods on one account

    Can I use two different I-Pod shuffles on one I-Tunes library?

    Yes, and you can then either sync the same or different content to them - iTunes should remember your selections for what you decide to sync to them

  • How to use two different ojdbc14.jar for two web application.

    Hi,
    I have two web application running in same tomcat, I need to use the two different ojdbc14.jar for two application, now both are taking the jars from tomcat common/lib directory, I tried copying the new ojdbc14.jar in web-inf/lib folder of one application, but it is not working.
    Could you please let me know whether this will take the jar from tomcat by befault or from web-inf, and a solution how to proceed with this.
    Thanks in advance.

    Yes, I tried removing the jars from common/lib, but as the connection string is mentioned inside the server.xml it is showing db connection error while trying to connect to the database

  • How to use two different accounts in iTunes

    I have purchased apps under two different email accounts and I am now unable to use the initial account.  Having deleted some apps because of problems, I am recharged for the apps because apple will not accept the original password and user name.  When I try to add it to my apple account, I get a message that this particular user name is already in use.  (yes, by me!)  Please help.

    Contact Apple about your iTunes accounts and maybe they can combine the two.
    http://www.apple.com/support/itunes/contact/

  • How to use two different packages which in  different directories?

    In my progrom, I'm using two differnet packages that in two different directories, but if I use classpath , the program can only be in one environment, so what can I do?

    or you set your classpath to the first common dir they have, and specify the packages from that dir on...
    or you just simply copy (you don't have to move it) the one package together with the other package...
    by the way you can add multiple paths to your classpath...
    between the paths you specify a ";"
    if i'm not mistaken...
    SeJo

  • How to use two different boot images in the same task sequence

    I have a need to use Two boot images in the same task sequence. The reason is I'm deploying ZTI to McAfee encrypted devices which I have already done with McAfee v6 Encryption successfully.
    Here's where my problem comes in. We are about to deploy McAfee v7 which means we will have a mix of v6 and v7 in our environment. I must have two special Boot images one with v6 drivers and one with v7 drivers in order for my process to work. I don't see
    a way right now to assign more than one boot image to a task sequence. Is there any way to do this?
    If I can't do that then I will have to create two task sequences and target collections based on the Endpoint Encryption version to deploy to.
    If anyone has suggestions it would be much appreciated. Thank you

    Have you tested copying those files to %windir%\system32\drivers during the WinPE session (just enable commandline support to your boot image) to see if they need to be in there before the OS start? Test that and if they don't need to be there during the
    boot up of WinPE then:
    Create two packages (v6 and v7)
    "Run command line", use the package created earlier and just use "copy /Y .\*.* %windir%\system32\drivers" ...again, this should be run according to your needs, variable or some other check like I said

  • How to update two different tables by ony one sql query???

    Hi All,
    i need to update two different talbes in a single sql query..
    i m using the following query
    UPDATE FT_User_Alert SET Subscription = 'W' where product_key=1 and measure_key = 12
    AND
    UPDATE LU_Monthly_Alert_Budget_Sheet SET Min_Red_Range ='16.0' AND Max_Green_Range ='24.0'AND Max_Red_Range ='27.0'AND Min_Green_Range ='16.0' where product_key='1' and measure_key = 12
    i m getting the following error:
    Odbc driver returned an error (SQLExecDirectW).
    Error Details
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43093] An error occurred while processing the EXECUTE PHYSICAL statement. [nQSError: 17001] Oracle Error code: 936, message: ORA-00936: missing expression at OCI call OCIStmtExecute: UPDATE FT_User_Alert SET Subscription = 'W' where product_key=1 and measure_key = 12 AND UPDATE LU_Monthly_Alert_Budget_Sheet SET Min_Red_Range ='16.0' AND Max_Green_Range ='24.0'AND Max_Red_Range ='27.0'AND Min_Green_Range ='16.0' where product_key='1' and measure_key = 12 . [nQSError: 17011] SQL statement execution failed. (HY000)
    SQL Issued: EXECUTE PHYSICAL CONNECTION POOL writeback UPDATE FT_User_Alert SET Subscription = 'W' where product_key=1 and measure_key = 12 AND UPDATE LU_Monthly_Alert_Budget_Sheet SET Min_Red_Range ='16.0' AND Max_Green_Range ='24.0'AND Max_Red_Range ='27.0'AND Min_Green_Range ='16.0' where product_key='1' and measure_key = 12
    but when i m ushin the same query in Microsoft SQL Server it executes properly:
    please help me out...

    There's no valid syntax for this, but there are some tricks you could do to achieve it.
    i) You could place an update trigger on TABLE1 to update TABLE2 automatically.
    ii) You could define a view across both tables and add an INSTEAD OF UPDATE trigger to it to maintain them.
    If I had to do this I'd choose option2, but frankly I'd just be running two updates if it really was me.

Maybe you are looking for