Remote Database connection throught JDBC-ODBC

Hi everybody
I've developed an application which connects to a MS Access database throught the JDBC-ODBC bridge; if the database is on my local machine I've no problem at all, but I now need to connect to a database on a remote PC. I've set the DSN entry for the database on the remote computer and try to connect using something like:
String db_name="jdbc:odbc:remote_pc_name\\\\DSN_db_name";
Properties db_prop=new Properties();
db_prop.setProperty("user","username");
db_prop.setProperty("password","user_password");
Connection dbconn=DriverManager.getConnection(db_name,db_prop);
but the ODBC driver gives me the message
"[Microsoft][ODBC Driver Manager] DSN not found and driver not specified.
I've tried other possible "connection strings" but I always get the same message.
The software works properly if I connect to the local DB with:
String db_name="jdbc:odbc:DSN_db_name";
Any idea how to connect to a remote DB through ODBC?
Thanks

No need for a separate thread really is there? its still relevant to the original.
import java.awt.*;
import java.sql.*;
public class JDBC1 extends Frame {
     private static final String DB = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=\\\\http:\\\\www.cs.stir.ac.uk\\~dcl\\databasename.mdb";
     public static void main(String[] arguments) {
          try {
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
               System.out.println("Driver registered!");
                     Connection conn = DriverManager.getConnection(DB, "", "");
               System.out.println("Connected!");
               Statement st = conn.createStatement();
               System.out.println("Statement created!");
               ResultSet rec = st.executeQuery("SELECT * FROM people");
               System.out.println("Queried!");
               while( rec.next() ) {
                    System.out.println( rec.getString(2) );
               st.close();          //close the statement
               conn.close();          //close the connection
          catch( SQLException s ) {
               System.out.println("SQL Error: "+ s.toString() + " " + s.getErrorCode() );
               s.printStackTrace();
          catch( Exception e ) {
               System.out.println("Error: "+ e.toString() + e.getMessage() );
}

Similar Messages

  • Getting Multiple Recordsets using A Single Connection using jdbc-odbc

    I have a java application which uses sql 7.0 database server. I want to have multiple recordsets created using a single connection using jdbc-odbc bridge. Kindly let me know the procedure.

    Well, you create a recordset, then you create another one, and so on. Are you actually having a problem or you just don't know where to start?

  • Error in Remote Database Connection

    I am trying to establish a connection for other database through remote database connection whenever i click the test connection i am getting the error like
    Bad Connection
    GetConnection failed: Caught Exception from getUrlAndDriver
    In trace file it shows like
    PSAPPSRV.5794 (42)      1-26493 14.30.43 19.832981 Cur#1.5794.LN290401 RC=0 Dur=0.000098 COM Stmt=SELECT VERSION FROM PSVERSION WHERE OBJECTTYPENAME = 'SYS'
    PSAPPSRV.5794 (42)      1-26494 14.30.43 0.020306 Cur#1.5794.LN290401 RC=0 Dur=0.000064 COM Stmt=SELECT VERSION FROM PSVERSION WHERE OBJECTTYPENAME = 'SYS'
    PSAPPSRV.5794 (42)      1-26495 14.30.43 0.016844 >>> start Nest=00 MISCTOOLS_WRK.TEST_CONNECT.FieldChange
    PSAPPSRV.5794 (42)      1-26496 14.30.43 0.000013 >>>>> Begin MISCTOOLS_WRK.TEST_CONNECT.FieldChange level 0 row 0
    PSAPPSRV.5794 (42)      1-26497 14.30.43 0.000019 1: DoSaveNow();
    PSAPPSRV.5794 (42)      1-26498 14.30.43 0.022858 <<< end Nest=00 MISCTOOLS_WRK.TEST_CONNECT.FieldChange Dur=0.022891 CPU=0.000000 Cycles=3
    PSAPPSRV.5794 (42)      1-26499 14.30.43 0.003037 >>> resume Nest=00 . MISCTOOLS_WRK.TEST_CONNECT.FieldChange
    PSAPPSRV.5794 (42)      1-26500 14.30.43 0.000028 1: DoSaveNow();
    PSAPPSRV.5794 (42)      1-26501 14.30.43 0.000004 2: &oRd = CreateJavaObject("com.peoplesoft.pt.remotedb.PSJDataSource");
    PSAPPSRV.5794 (42)      1-26502 14.30.43 0.781008 3: &b = &oRd.TestConnection(PSREMOTEDBDEFN.REMOTEDB_ID.Value);
    PSAPPSRV.5794 (42)      1-26503 14.30.43 0.000041 Fetch Field: PSREMOTEDBDEFN.REMOTEDB_ID Value=HCM91PRD
    PSAPPSRV.5794 (42)      1-26504 14.30.43 0.019209 Cur#2.5794.LN290401 RC=0 Dur=0.000097 COM Stmt=SELECT REMOTEDB_ID,DBTYPE,DESCR,LOCAL_CONNECT_FLAG,REMOTEDBCONNTYPE,REMOTEDBNAME,DBSERVER,DB_PORT,INFORMIXSERVERNAME,USERID,PASSWORD FROM PSREMOTEDBDEFN WHERE REMOTEDB_ID = :1
    PSAPPSRV.5794 (42)       1-26505  14.30.43    0.004232 Database Options: override_connection_reset: 0
    PSAPPSRV.5794 (42)      1-26506 14.30.43 0.048569 4: If &b Then
    PSAPPSRV.5794 (42)      1-26507 14.30.43 0.000003 7: WinMessage("Bad connection", %MsgStyle_OK);
    PSAPPSRV.5794 (42)      1-26508 14.30.43 0.000055 8: If &oRd.success() = False Then
    PSAPPSRV.5794 (42)      1-26509 14.30.43 0.000013 9: WinMessage(&oRd.getErrStr(), %MsgStyle_OK);
    PSAPPSRV.5794 (42)      1-26510 14.30.43 0.000014 10: End-If
    PSAPPSRV.5794 (42)      1-26511 14.30.43 0.000062 >>> reend Nest=00 . MISCTOOLS_WRK.TEST_CONNECT.FieldChange
    PSAPPSRV.5794 (42)      1-26512 14.30.43 0.009340 Cur#1.5794.LN290401 RC=0 Dur=0.000075 COM Stmt=SELECT PTTAPAGECUST FROM PSUSRTAPAGECUST WHERE MENUNAME = :1 AND PNLGRPNAME = :2 AND PNLNAME = :3 AND OPRID = :4
    PSAPPSRV.5794 (42)      1-26513 14.30.43 0.000009 Cur#1.5794.LN290401 RC=0 Dur=0.000000 Bind-1 type=2 length=9 value=UTILITIES
    PSAPPSRV.5794 (42)      1-26514 14.30.43 0.000003 Cur#1.5794.LN290401 RC=0 Dur=0.000000 Bind-2 type=2 length=14 value=REMOTEDB_TABLE
    PSAPPSRV.5794 (42)      1-26515 14.30.43 0.000003 Cur#1.5794.LN290401 RC=0 Dur=0.000000 Bind-3 type=2 length=8 value=REMOTEDB
    PSAPPSRV.5794 (42)      1-26516 14.30.43 0.000003 Cur#1.5794.LN290401 RC=0 Dur=0.000000 Bind-4 type=2 length=9 value=CAPIADMIN
    Edited by: abdul43 on Apr 11, 2013 12:19 AM

    Thank you for your help, RK.
    The problem was that sidadm was not the owner of ORA_NLS.
    Now I have another problem: when running startsap not boot disp + work.

  • How to know the TNS_ALIAS of a Remote Database Connectivity ??

    Hi ,
    I have a Remote DB Connection and a Local DB Connection in my System
    I want to create the Same Table and Data From my Remote DB Connection to Local DB Connection .
    I have used
    CREATE TABLE LOCAL_TABLE AS SELECT * FROM REMOTE_TABLE@TNS_ALIAS;
    But How can i know this TNS_ALIAS of the Remote Database connection (I just jave XE under my System)

    In "... FROM REMOTE_TABLE@TNS_ALIAS"
    The TNS_ALIAS is actually a Db link and not a tns alias!
    user10503747 wrote:
    i tried everyhting but its coming as no results .What is "everything", "its" and "no results" in this context? Please explain, and don't worry about copy-paste taxes.

  • Access database/ java application/ jdbc odbc

    i am building an access database with a java application and get the following error message when i try to run the application. the log in window that i have does not have a password text field, only a field for the odbc name.
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Not a valid password.
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6106)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6263)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:2488)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:317)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:160)

    User/password are usually necessary to set up the ODBC source. So you may need find out who set up your ODBC source. Or you need find the correct user/password and reset the ODBC source.
    PC

  • Remote database access via JDBC?

    Hello,
    Can anyone give me info on accessing remote databases (i.e. Microsoft
    Access, etc) from Java programs (Servlets, JSP's, Classes) residing on the
    iSeries (AS400) or perhaps any platform?
    I currently have a couple of web applications set up on the Websphere App server that access DB2/400 database and I also have some Java Classes on PC's that access MS Access datafiles. I would like to begin writing the majority of my applications that run on the iSeries (or host system) that can remotely access other databases on our network.
    Any info would be of great help to me.
    Thank you
    Don

    I don't know of any existing Access JDBC drivers that support remote access, after all, the Access database itself is not remote access capable except via file sharing. One possibility is to look for a Type 3 JDBC driver that supports reuse of other Type 1 (ODBC bridge), Type 2 (Java/Native Mix) and Type 4 (pure Java)JDBC drivers on the server side.
    If you were using WebLogic Server, I suppose you could use its remote JDBC facilities, but that won't help you.
    One problem you will have to face is that Access JDBC drivers are not (if I recall) meant to be used in a multithreaded fashion. Good luck. By the way, it might be far simpler to port the Access database to DB2/400.
    Chuck

  • Compile error when connecting to JDBC:ODBC

    Hi
    I am not used to java so probably this is an enivorment problem, but I cannot fix, please help!
    FOLLOWING CODE
    import java.sql.*;
    public class DBtest {
    public static void main (String args[]) {
    String jdbcDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
    String protocolHeader = "jdbc:odbc:";
    String dbName = "myodbc3-test";
    String user = "";
    String password = "";
    Class.forName(jdbcDriver);
    Connection cn =
    DriverManager.getConnection(protocolHeader+dbName, user, password);
    GENERATES FOLLOWING COMPILING ERROR
    cd c:/Javakod/NewFolder/
    javac -classpath C:\Javakod\ DBtest.java
    DBtest.java:17: incompatible types
    found : java.sql.Connection
    required: NewFolder.Connection
    DriverManager.getConnection(protocolHeader+dbName, user, password);
    ^
    1 error
    What is wrong? I am using a Win2000.

    This code compiles and runs fine on my Windows 2000 machine running JDK 1.4.1:
    import java.sql.*;
    public class AnotherConnectionTester
        public static void main(String [] args)
            String jdbcDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
            String protocolHeader = "jdbc:odbc:";
            String dbName = "myodbc3-test";
            String user = "";
            String password = "";
            try
                Class.forName(jdbcDriver);
                Connection cn = DriverManager.getConnection(protocolHeader+dbName, user, password);
                DatabaseMetaData meta = cn.getMetaData();
                System.out.println("product name: " + meta.getDatabaseProductName());
            catch (Exception e)
                e.printStackTrace(System.err);
    }I set up an ODBC DSN myodbc3-test to connect to an Access database. It was no problem. I guess that doesn't explain why your post didn't work. I changed the name of the class and added that meta data output so I could make sure that it connected. - MOD

  • Remote Database connection error on local database while running a procedur

    Dear Gurus,
    I am trying to run a procedure to grant Select Access to all objects of a schema to all schema but getting below error messages:
    Error report:
    ORA-02019: connection description for remote database not found
    This is on local database and all required privileges have been given to run this procedure but I dont understand why this error is being thrown every time. I am able to fetch all the tables directly (i.e. SELECT object_name FROM user_objects where OBJECT_TYPE IN('TABLE','VIEW','MATERIALIZED VIEW') AND STATUS='VALID')
    Kindly let me know if you have any solution.
    Procedure detail:
    declare
    sqltxt varchar(250);
    cursor course_det is
    SELECT object_name FROM user_objects where OBJECT_TYPE IN('TABLE','VIEW','MATERIALIZED VIEW') AND STATUS='VALID';
    v_objnm user_objects.object_name%type;
    begin
    open course_det;
    loop
    fetch course_det into v_objnm;
    exit when course_det%notfound;
    sqltxt :='GRANT SELECT ON ' || v_objnm|| ' TO public with grant option';
    EXECUTE IMMEDIATE sqltxt ;
    end loop;
    end;
    System detail:
    Oracle 11.2.0.3/Linux 5.3
    Ragards.
    Edited by: 877938 on Mar 20, 2013 12:27 AM

    Hi,
    It seems you are fetching records from one database to other. for that you need to create dblink for that.
    Create dblink first and then try to fetch records using that dblink.
    ORA-02019: connection description for remote database not found
    Cause: An attempt was made to connect or log in to a remote database using a connection description that could not be found.
    Action: Specify an existing database link. Query the data dictionary to see all existing database links. See your operating system-specific Net8 documentation for valid connection descriptors. 

  • Error database connection in JDBC Adapter

    Hi Experts,
      I am facing errror database connection problem in production system.
    My interface was working fine in production till yesterday but suddenly from today i am facing the error connection problem.
    Below is the error message i am getting.
    Error during database connection to the database URL 'jdbc:oracle:thin:@<ip>:<port>:"' using the JDBC driver 'oracle.jdbc.driver.OracleDriver': 'com.sap.aii.adapter.jdbc.sql.DriverManagerException: Cannot establish connection to URL 'jdbc:oracle:thin:@'jdbc:oracle:thin:@<ip>:<port>:": SQLException: Io exception: The Network Adapter could not establish the connection'
    Please advice what would be the problem.
    I have checked the IP by pinging, its working fine.
    Thanks,
    Swetha Reddy

    Hi Sarvesh,
      I have tried with deactivaing and activating channel.. but facing same problem..
    Nio firewall settings has been changed either side..
    Regarding patch i am not sure what patch should be applied..
    i can tell that BASIS has not applied ant patch..
    Thanks,
    Swetha Reddy

  • Remote Database Connection DB2 - Oracle

    Hi All
    We need to maintain a remote db connection in DBACockpit. We are on DB2 UDB and we need to connect to Oracle. We have all the connection details.
    Now my query is do we need to maintain connection details at DB2 level also , or is it enough to maintain them in DBACockpit.
    Basically i need to connect from my SAP BI system which is on DB2 UDB 9.1 to Oracle Database.
    In oracle we can connect to different databases using TNS functionality, is something there like TNS in DB2 where we have to maintain the remote DB connection details? If yes request you to provide some relevant document for the same
    Thanks in Advance.
    Regards
    Kaleem.

    Hi Kaleem,
    if you want to administer your ORACLE database through DBACockpit, you need to prepare your system for a DBSL multiconnect to ORACLE as described in note 339092 ( i.e. install ORACLE client, ORACLE DBSL library, etc. ).
    This multiconnect can also be used for BI Connect.
    If you just want to query some ORACLE tables in your DB2 system, you may also consider to use the DB2 federation feature to create ncicknames within your DB2 database that point to ORACLE tables. In this case I suggest to consult the DB2 manuals on how to do this. You may also have to install an additional DB2 license for the hererogenous federation feature to create nicknames to ORACLE tables.
    Regards
                   Frank

  • Memory leak when using database connectivity toolset and ODBC driver for MySQL

    The "DB Tools Close Connection VI" does not free all the memory used when "DB Tools Open Connection VI" connects to "MySQL ODBC Driver 3.51".
    I have made a small program that only opens and close the connection that I run continously and it's slowly eating all my memory. No error is given from any of the VI's. (I'm using the "Simple Error Handler VI" to check for errors.)
    I've also tried different options in the DSN configuration without any results.
    Attachments:
    TestProgram.vi ‏16 KB
    DSNconfig1.jpg ‏36 KB
    DSNconfig2.jpg ‏49 KB

    Also,
    I've duplicated the OPs example: a simple VI that opens and closes a connection. I can say this definately causes a memory leak.
    Watching the memory:
    10:17AM - 19308K
    10:19AM - 19432K
    10:22AM - 19764K
    10:58AM - 22124K
    Regards,
    Ken
    Attachments:
    OpenCloseConnection.vi ‏13 KB

  • MS SQL Server 2005 Remote Database Connection

    Hello Friends,
    I have a database in SQL Server 2005, i installed SQL server with windows authentication. Now when I tries to connect to the server using Type 3 jdbc. I downloaded jdbc 1.2 driver from,
    http://msdn2.microsoft.com/hi-in/data/aa937724(en-us).aspx
    now i want to connect to the database from remote machine(different network).
    How can i achieve this, and what setting i have to make to the sql server?
    Any suggestion will be greatly appreciated.
    Regards
    Mohneesh

    okey i done with some experiment.
    now i am able to do it from local machine with the following code
    String url="jdbc:sqlserver://LocalIP:1433;integratedSecurity=true;";
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    Connection conn = DriverManager.getConnection("url");
    now when i move to remote system and change the Local IP to remote IP(server has static IP)
    it comes up with SQLException: Login failed.for user ''.
    com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user ''. The user is not associated with a trusted SQL Server connection.
    please help me its kinda urgent.
    Regards
    Mohneesh

  • Remote Database connection

    hi all
    i am using
    mysql-connector-java-3.0.16-ga-bin.jar
    to connect to mysql 4.0.18
    the scenario is like this
    the application connects to some 20 databases(mysql 4.0.18) which are available at 20
    database servers one by one. i mean to say that this is not a multi-threaded application.
    In this driver = com.mysql.jdbc.Driver
    dcsIP = variable for 20 database
    remote_db, remote_username and remote password are also variables
    Class.forName(ResourceLoader.getString("driver"));               
    DriverManager.setLoginTimeout(60);
    connection =
    DriverManager.getConnection("jdbc:mysql://"+dcsIP+"/"+ResourceLoader.getString("remote_
    db"),ResourceLoader.getString("remote_username"),ResourceLoader.getString("remote_pass
    word"));
    statement = connection.createStatement();
    statement.setQueryTimeout(60);
    Using the above code i am able to get information from 20 database's and if at all there is
    no mysql service running at the given dcsIP, i am getting exception and that is declared as
    no connection.
    But the actual problem is, for one server( identified the IP say XXX.XXX.X.XXX) among these
    20, the application is loosing the control ie not even an exception is thrown. What might be
    the reason.
    For one thing i am sure is not the memory inconsistencies as the application is running fine
    with 25 servers even ( excluding the server at XXX.XXX.X.XXX);
    As this system is running continouly, if i restart the system i am able to get the connection
    for XXX.XXX.X.XXX, but again after 3 to 4 days, not getting any response and the
    application is getting blocked.
    Kindly send me ur suggestions

    Sounds like a network problem to me. Probably nothing to do with JDBC. Have you considered asking your network people to look at the problem?

  • Remote database connections

    Hello. Does anyone out there know how i could connect to an oracle 8i database that is residing on a different server to my jsp pages? I indicate the domain name as well as the database name in the url (using jdbc) but i still get a TNS could not resolve service name error. Any advice would be greatly appreciated.

    Have you installed the oracle JDBC driver on your server?
    Try this if you do have the driver installed:
    private static final String driver = "oracle.jdbc.driver.OracleDriver";
         private static final String user = "blablabla";
         private static final String pass = "blablabla";
         private static final String dbURL = "jdbc:oracle:thin:@IP address for the oracle databse here:1521:database name";

  • Remote Database Connection On Windows 7

    Hi
    I have installed Oracle 10g database on Windows 7 and i want to access EM (enterprise manager) from another machine on which windows xp os installed both are 32 bit Operating Systems. when i type complete url of remote machine EM but it time out and take too long time, can you tell me is there any solution and is this security problem ? both computer are connected with wifi router and when i ping to remote machine its response is ok and both machine on WLAN (Wireless Local Area Network). Em on remote machine is running Fine
    Thanks in Advance

    Dear ,
    Please check both sides firewall setting .
    right-click the networking --> properties --> tabpage"advance "--> firewall setting.
    I met this problem before .
    Just shutdown firewall then try to connect again.
    tnks.
    K.Y.

Maybe you are looking for

  • No Airprint in the Share Menu!

    if i press the share icon in any of the apps that  there is no print option in photos are only the "send as e-mail" and "wallpaper" option

  • Catalog Backup Piece Manually

    We are currently running Oracle 10.2.0.4 and IBM TSM to do our backups, but we moved to a new machine and some of our older backups are sitting on tape in TSM and i need to manually catalog these pieces, I logged a SR with Oracle and they sent me the

  • Calling Form/Block from another Form/Block

    I have several form/blocks in my application with field COMPANY_NAME/ID. How can I navigate from more then 1 form/block to the same Form (with Company information) From 1 Block it is easy: Where clause: :t_bedrijf_lijst.bedr_id = t_bedrijf.bedr_id Bu

  • I keep getting "The application QuickTime player can't be opened" -1712

    I just upgraded to Lion on Thursday, and now I can't open QuickTime. Whenever I try to, I get the message "The application QuickTime player can't be opened" -1712 Any ideas?

  • Soa 11g best practices

    Is there some Oracle doc describing best practices for SOA Suite 11g Thanks - casey