Connecting to a dsn

so far, i'm connecting directly to oracle using jdbc driver and this is
my connection string which works just fine
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:@servername-1:portname:sid","username", "password");now i have a DSN from an RDB and i was wondering how the connection string would be to connect to a DSN and how the driver connection string would also be
also, what driver should be used? would that need a jdbc-odbc driver?
thanks

my development environment is in windows but when this gets deployed to production, it will be deployed in linux.
so it will not work then?
this is my class:
package connection;
import java.sql.*;
import java.io.*;
public class WksDBConnection
     private Connection con;
     public WksDBConnection()
          try
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              con = DriverManager.getConnection("jdbc:oracle:DSNName","usernme", "pswrd" );
        catch (Exception e)
             e.printStackTrace();
     public Connection getConnection()
          return con;
     public void close()
          try
               con.close();
          catch(Exception e)
               e.printStackTrace();
     public static void main(String[] args)
          Connection con;
          try
               con = new WksDBConnection().getConnection();
               Statement stmt = con.createStatement();
                ResultSet rs = stmt.executeQuery("SELECT count(*) FROM WLOT");
                rs.next();
                int num = rs.getInt(1);
                System.out.println(num);
                 con.close();
              rs.close();
              stmt.close();
         catch (SQLException se)
                System.out.println("SQL Exception: " + se.getMessage() + "not connected");
                se.printStackTrace(System.out);
}

Similar Messages

  • Is connection NAME property DSN or connection name

    Hi We run std 2008 R2.  I have what I hear is an odbc connector to a btrieve general ledger system.
    I also hear that I have to and have created two separate odbc DSN's on my local to extract data from this source for two different companies.
    I want to use the same conn mgr in ssis for otherwise identical DFTs in both companies and am hoping by making the conn mgr "name" property an expression, I'll be able to pull that off.  But am not sure what that property is for. 
    My recollection is that there was trouble going with "use connection string" (too bad cuz that property is obvious) instead of "use user or system dsn" when setting up the conn mgr but wouldn't swear to that.   
    Can someone advise?  I'll keep looking on the internet but am coming up short so far. 
    my provider is ".net Providers\odbc data provider".  I didn't see a property for my oledb sources to use an expression based conn mgr but may look again at that alternative.  Unfortunately the going is slow cuz ssis keeps locking up in
    the gui presumably because its checking this connection's availability periodically.

    Hi db042190,
    A data source name (DSN) is a data structure that contains the information about a specific database that an Open Database Connectivity ( ODBC ) driver needs in order to connect to it. Included in the DSN, which resides either in the registry or as a separate
    text file, is information such as the name, directory and driver of the database, and, depending on the type of DSN, the ID and password of the user. Name is just the name of the connection manager. They are completely different.
    If you want to change the DSN dynamically, I suggest you configure the ConnectionString property via Expression.
    The following screenshot is for your reference:
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • DB2 Connection VIA ODBC DSN

    Can anyone point me to good 'step-by-step' guide to setting up a HS connection to an AS400 DB2 database using a ODBC connection.
    I have an ODBC DSN on set up but I'm not sure how set-up my tsnnames.ora or listener.ora, I've looked at several posts in this thread but I'm still struggling.
    I basically need to be able to something like 'select something from sometable@AS400link'
    Thanks
    Bri

    Tak,
    Thanks once again, I still can't get this to work, here's what I have:
    On the DB server itself:
    \hs\admin\initFRUIT.ora contrains:
    HS_FDS_CONNECT_INFO = SPONGE
    HS_FDS_TRACE_LEVEL = 0
    \network\admin\listener.ora contains:
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <name of the host PC>)(PORT = 1521))
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = E:\oracle\ora81)
    (PROGRAM = extproc)
    (SID_DESC =
    (SID_NAME = FRUIT)
    (ORACLE_HOME = E:\oracle\ora81)
    (PROGRAM = hsodbc)
    (SID_DESC =
    (GLOBAL_DBNAME = <name>)
    (ORACLE_HOME = E:\oracle\ora81)
    (SID_NAME = <name>)
    \network\admin\tnsnames.ora contains:
    JELLY =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <name of the host PC>))(PORT = 1521))
    (CONNECT_DATA = (SID=FRUIT))
    (HS=OK)
    I created a public database link as follows:
    create public database link custard
    using 'JELLY'
    My ODBC DSN is pointing to an SQL Server
    Unfortunately I am still getting the same error??
    Thanks for your help.
    Brian

  • Automatically create ODBC DSN connection with special port and password. Add-OdbcDsn cmdlet

    Hi,
    I first posted a question in the SQL forum but I'm posting it here instead because its a Powershell question.
    In a non-persitent VDI enviroment we are trying to automatically create a ODBC DSN connection to a SQL server.
    We are using Windows 8.1 so we also have Powershell 4 together with the add-odbcdsn cmdlet. 
    But when trying to add set -SetPropertyValue for network port different than default and a password we get an error.
    here is the command:
    Add-OdbcDsn -Name test -DriverName "SQL Server" -DsnType User -SetPropertyValue @("PWD=test", "SERVER=10.0.0.1")
    and here is the error message:
    Add-OdbcDsn : Attempt to set the {UID or PWD} key of a DSN. These keys should not be stored in the registry for securit
    y reason. Provide the credential information at runtime via SQLDriverConnect, SQLConnect or SQLBrowseConnect.
    At line:1 char:1
    + Add-OdbcDsn -Name test -DriverName "SQL Server" -DsnType User -SetPropertyValue @ ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (MSFT_OdbcDsnTask:Root/Microsoft/...SFT_OdbcDsnTask) [Add-OdbcDsn], Cim
    Exception
    + FullyQualifiedErrorId : MI RESULT 4,Add-OdbcDsn
    NB!:  this command does not contain a port number, but when adding it without a password(PWD string) we just the default port.

    Hi Primeid,
    Agree with Jrv, we cannot store  UID and PWD in an ODBC datasource, For example, you can create a DSN using the user interface but if you look at the DSN stored in the registry the UID and PWD are not stored.
    ODBC it is always required when you connect using a DSN that the caller supply UID and PWD if they want to use standard login during connection time. 
    These similar discussion are for your reference:
    Creating ODBC DSN for SQL Native
    Client fails for not-integrated authentication
    is user name and password required in ODBC admin / User DSN?
    In addition, to read data from a SQL Server database using an ODBC DSN with SQL Authentication via powershell, please refer to this script:
    Open SQL database with ODBC DSN and SQL AuthenticationIf
    there is anything else regarding this issue, please feel free to post back.
    If you have any feedback on our support, please click here.
    Best Regards,
    Anna Wang
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • Creating DSn  connecting database in the same drive)

    Hi I am creating a DSn by Java prograame
    I have a Java file DSN.java where a fynction is written
    createDSN(String driverType, String dsnName, String filePath)
    I have all my .java files in D: Drive
    and when i am giving filePath as
    String fP = "\\folder1\\NameOfMyAccessfile.mdb"
    it is trying to create DSN( name as dsnName ) by mapping it to file in C Drive but normally it should try to create DSN connecting the database in the root directory.(in my case it is D drive)
    My JDk is in C drive
    Please help me how to create DSN when the database is in the root directory?
    Thanks

    salam,
    je voulais te demander si tu peux:
    *comment tu fais pour creer un DSN en java directement.
    *comment tu fais pour avoir la liste de tes DSN sur ta machine,
    *comment tu fais pour te connecter via une DSN.
    --- je te remercie d'avance de ta collaboration;

  • DSN Less Connections

    Hi,
    The majority of our ASP pages use a DSN Less connection. An example is
    Set dbConnection = Server.CreateObject("ADODB.Connection")
    dbConnection.open "Provider=MSDAORA;Data Source=tnsname;User ID=username;Password=password"
    However I cannot get this to work with the instant client. I can even change the provider to "Oracle in instantclient10_2" and it errors out. DSN Connections like the one below work great
    Set dbConnection = Server.CreateObject("ADODB.Connection")
    dbConnection.open "DSN=dsn_name;UID=username;PWD=password"
    But I do not really want to go around to all of web servers and recode them (nor make the programmers do it). Is there a way to use DSN Less connections with Instant Client? Am I using incorrect syntax, or is it just not possible currently?
    Thanks in advance.
    //Karl

    I finally found an example that worked. The biggest clue to troubleshooting these connection is to reboot the server as IIS reset does not always clean up its cache.
    Anyway the answer was this
    Set dbConnection = Server.CreateObject("ADODB.Connection")
    dbConnection.open "Driver={Oracle in instantclient10_2};Dbq=<db name>;UID=<username>;PWD=<password>;"
    Thanks
    //Karl

  • Help on Livecycle/DSN...API or some type of Active X solution to help making connection

    I have a solution that I'm trying to come up with.
    LiveCycle is a relatively handy tool for automating input from ODBC data
    sources to download to forms
    What we would like to do is automate the process of setting up the DSN used
    by LiveCycle and automate the process of making the connection to that DSN
    to populate the fields in the forms. Automating the DSN setup is done. But
    what I'm looking for is an API or some type of Active X solution to help
    with making the connection, populating the forms using LiveCycle and
    printing the PDF output file. Can you help me with this?
    Currently I'm using LiveCycle Designer 8.0 as part of the Adobe Acrobat
    suite. Can I use this, or do I need to look at a different software package?
    Thank you for any assistance you can provide me with.

    Hiho Ashley,
    Iam sorry that I can´t answer your question about the Active-X-Stuff and I truely doubt, that you will look in this thread again. But Iam interested in your solution for automated build of an DSN. Is it within the PDF-File, so not every user wanting the the PDF to be filled have to settle up an extra connection? And does it work, if the user has no permission to make a DSN on his own?
    Hope, someone can reply
    Greetings

  • ODBC DSN Connection

    Hi All,
       I have a report that needs to connect to a local( to the server) DSN Connection on the Crystal Server 2008 and am having difficulty viewing the report. I am getting connection errors. My question is: How do I configure the report under "Database Configuration" to get it to connect to the DSN Connection on the server?
    Thank you in advance.

    Create the same DSN or the datasource name as on the server and update in Crystal reports using set datasource location. What database is it pointing to?
    Thanks!

  • Dsn less connection

    hi guys...
    i have problem in connecting to the database.
    i am having oracle as database.
    I want to connect from jsp page to oracle...
    Here important thing is i want to connect without the dsn.
    Plz help me urgent...

    this is the error................................
    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    at org.apache.tomcat.util.depend.DependClassLoader.loadClassInternal1(DependC
    lassLoader.java:186)
    at org.apache.tomcat.util.depend.DependClassLoader12$1.run(DependClassLoader1
    2.java:92)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.tomcat.util.depend.DependClassLoader12.loadClass(DependClassLoa
    der12.java:90)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:310)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:115)
    at ebsipl.search.<init>(search.java:43)
    at java.lang.Class.newInstance0(Native Method)
    at java.lang.Class.newInstance(Class.java:232)
    at java.beans.Beans.instantiate(Beans.java:202)
    at java.beans.Beans.instantiate(Beans.java:46)
    at EBSIPL.search_1._jspService(search_1.java:66)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
    at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
    at org.apache.tomcat.core.Handler.service(Handler.java:235)
    at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:
    917)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
    at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http1
    0Interceptor.java:176)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.j
    ava:516)
    at java.lang.Thread.run(Thread.java:479)
    test query select distinct(ccity) from cmaster
    java.lang.NullPointerException

  • Dsn-less jdbc connection

    how do i connect w/out dsn?

    Try the JDBC forum where this question is asked regularly. If it is not in the FAQ for the forum then you should be able to search and find many related posts.

  • Can not see the schema under the new connection -- Please help

    The database is Oracle.  Recently I requested our DBA to do a database refresh, and here was she did.
    1. Drop the user (TDEV, schema owner) in Dev.
    2. Recreate the user, TDEV, with the same password, roles and tablespaces.
    3. Using Oracle export command to export data from production under schema owner, TPROD.
    4. Using Oracle import command to import the dump file from TPROD to TDEV.
    5. Both export and import were successful.
    Dev and Production are in two different databases.
    After the importing, using SQL*PLUS I logged into Dev database as schema owner "TDEV", and were able to select all tables.  I also verified there was no schema or user called TPROD in Dev database, and there is no TDEV in Production database.
    However, in Crystal Report, both 10 and XI, when I made the new ODBC (RDO) connection to Dev DSN and logged in as the schema owner user "TDEV", I noticed there is TPROD listed below, but no TDEV.  I tried to select the tables listed underneath TPROD, and got the following error message: "Query Engine Error: '42S02:[Oracle][ODBC][Ora]ORA-00942: table or view doesn't exist'"
    Any ideas or helps are welcome!!

    Try to create a brand new DSN connecting to Dev

  • Error while connecting to SQL Server 2000 using Heteregenous Services 11g

    Hope this is the right thread to post on! We have been given the challenge of connecting to and reading data from a SQL Server 2000 database.
    Our Infrastructure guys have set up the network access.
    The SQL Server DB is set to windows NT Authentication only (N.B. NOT Mixed Mode) as there is an application running against the DB locally that will not run under Mixed Mode.
    Our Oracle partner has download and installed the 11g Heteregenous Services. all works fine until the point we try to create the DBLink and then connect to the SQL Server DB when we get:
    SQL> CREATE DATABASE LINK infoteam1.sco.infoteam.co.uk CONNECT TO "sco.infoteam.co.uk/infoteam" IDENTIFIED BY "########" USING 'dg4msql';
    Database link created.
    SQL> select * from "systables"@infoteam1.sco.infoteam.co.uk;
    select * from "systables"@infoteam1.sco.infoteam.co.uk
    ERROR at line 1:
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Oracle][ODBC SQL Server Driver][SQL Server]Login failed for user
    'sco.infoteam.co.uk/infoteam'. Reason: Not associated with a trusted SQL Server
    connection.[Oracle][ODBC SQL Server Driver]Invalid connection string attribute
    ORA-02063: preceding 2 lines from INFOTEAM1.SCO.INFOTEAM.CO.UK
    The question is can we (and if so how)?) connect to the SQL Server using an NT Windows Authorised account?
    Jeremy

    Hi,
    Please look at MOS note
    ORA-28500: Generic connectivity using ODBC DSN over mapped drive fails [ID 105210.1]
    Ora-28500 with Ms Sqlserver - Not associated with a trusted SQL Server connection [ID 333775.1]
    Regards,
    Edited by: gjilevski1 on Aug 31, 2010 8:23 AM

  • Trying to simply connect to Oracle with VBscript/ASP - and I cannot.

    This is rather embarrassing. I am pretty fluent with ASP and VBscript, and I have written many a web application connecting to Microsoft SQL Server. Now I have a need to connect to an Oracle database, and I'm beating my head against the wall.
    1) Web server is Windows Server 2003 SP1
    2) Using ASP (not ASP.NET) & VBscript
    3) I have installed the Oracle drivers on the server - it is version 10g
    4) The administrator of the Oracle database to which I want to connect has created a username and password for me to use from within my code
    5) Here is the code I am trying to run:
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open "Provider=MSDAORA;Data Source=XXXXXXX;User Id=YYYYYYY;Password=ZZZZZZZ;"
    That's it. 2 lines of code just trying to establish a connection. Using the user name and password provided to me by the administrator, and for Data Source I am using the IP address of the Oracle server (like I have done in the past when connecting to SQL Server). I receive the following error message when viewing this in a browser:
    Microsoft OLE DB Provider for Oracle error '80004005'
    ORA-12154: TNS:could not resolve the connect identifier specified
    Evidently, the Data Source I am using is not correct, but I was provided no other information from the admin. This is the first time any of us have tried to connect to Oracle using ASP/VBScript, so the administrator isn't sure what I need to do ... any help would be so appreciated.

    Hello,
    I got mine to work by setting up an ODBC System DSN and connecting to it. I think this bypasses the Microsoft driver, which might be what's causing the problem.
    Set Db = Server.CreateObject("ADODB.Connection")
    Db.Open "DSN=TEST;User ID=userid;Password=password;"
    Good luck, I've found it requires a lot of persistence...
    Al
    Springfield, MO

  • Unable to load the necessary SQL connectivity library

    I am installing an older (non-Microsoft) program (32bit) that manages mail online and it requires an access to SQL Server to create database to complete installation. I am installing it on Windows Server 2003 standard. This program
    I am installing recommends SQL Server 2000. We are now running SQL Server 2005 on a separate server. For connectivity, I installed SQL server 2005 tools (full install) on the same 2003 server as the program so that this program could manage to locate
    SQL server 2005 and connect to it in order to create necessary tables and complete the installation. I already manually created the database for this program on SQL Server 2005. I created ODBC SQL Server connection string (User DSN). However, during
    installation, I am getting the following error message:
    ERROR: Setup is unable to load the necessary SQL connectivity library. This indicates that the proper client-side SQL utilities are not installed on your system. Setup cannot continue.
    Could this error be SQL Server version specific and the program only likes SQL 2000 client tools and not 2005? Are there major differences between libraries versions? Should there be something else configured? What am I missing? Thanks in advance.

    ERROR: Setup is unable to load the necessary SQL connectivity library. This indicates that the proper client-side SQL utilities are not installed on your system. Setup cannot continue.
    Could this error be SQL Server version specific and the program only likes SQL 2000
    client tools and not 2005?
    Tools are tools, not a connectivity library and by the error message the right connectivity library is missing. Ask the software vendor which one is required or look it up on the other machine, where the application works.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Error"Failed to open the connection"  - Named Instance of SQL Server 2005

    "Failed to open the connection" error, when connecting to the Named Instance of SQL Server 2005
    The report is throwing error, when changing the logon information dynamically through C#.
    Code
         string reportPath = @"D:\NET\TestReport\TestReport.rpt";
         ReportDocument reportDocument = new ReportDocument();
         reportDocument.Load(reportPath);
         foreach(CrystalDecisions.CrystalReports.Engine.Table table in tables)
              TableLogOnInfo tableLogonInfo = table.LogOnInfo;                         
              tableLogonInfo.ConnectionInfo.ServerName = @"TestServer\Instance1";  //Connnecting to Named instance of SQL Server 2005
              tableLogonInfo.ConnectionInfo.UserID = "sa";
              tableLogonInfo.ConnectionInfo.Password = "password";
              tableLogonInfo.ConnectionInfo.DatabaseName = "TEST_DB";
              table.ApplyLogOnInfo(tableLogonInfo);     
         crystalReportViewer1.ReportSource = reportDocument;
    Error Message
         Failed to open the connection.
         Failed to open the connection.
         C:\DOCUME1\PUGALE1\LOCALS~1\Temp\{DF9593A5-5C80-4CBC-ABC3-EC4EF204A7EB}.rpt
    The error is occuring only whenever i am connecting to the Named Instance of SQL Server 2005.
    Thanks in Advance
    Edited by: pugalendran p on Feb 2, 2009 10:32 AM
    Edited by: pugalendran p on Feb 2, 2009 10:43 AM

    Hi,
    Following solution might help you to resolve the issue.
    Solution1:
    Issue happens because universe connection to the Database is not responding and the Data Source Name is not configured to write SQL Server 2005 database.
    Resolution
    Created new DSN connection under SYSTEM DSN to SQL Server 2005 Database.
    Import the universe from the designer.
    Go to File->Parameters.
    Edit Connection.
    On the Database Middleware Page expand SQl Server 2005->Select SQL Server 2005 driver.
    Change the DSN to new DSN connection
    Test the connection.
    Save the Universe and Export it to the repository.
    Solution2:
    I am taking Oracle as an example over here.
    This can be caused when the SQLNET.ora is located in a remote location using mapped drives.
    Resolution
    To resolve,
    check the registry [HKLM\SOFTWARE\ORACLE] you should see a folder called HOME0
    look for any paths that contain a mapped drive partition
    Change the mapped drive letter to a UNC path (
    server\folder)
    Open a command prompt and do a tnsping using the tnsname and verify the location of the SQLNET.ora or TNSNAMES.ora
    If the path is not updated to the new path
    Reboot the server
    Regards,
    Sarbhjeet Kaur

Maybe you are looking for

  • PDFs Generated by google analytics are not able to print using Adobe Reader/Pro

    HI, I have fetch the reports from google analytics and tried to print it using adobe reader as well adobe reader pro in mac as well as in windows. Either or it gives me an error "The Document couldnt be printed" and "There were no pages selected to p

  • Check FM - SGOSSUB_CHECK_FB  having error 'Check FM ends with exception'

    Hi All, System ECC 6.0 Scenario --> When inbound IDOC type ORDERS05 fails system should sent notification. Event linkage is active for for BO --> BUS2032 Event --> Changed Receiver Type --> Subscribe In Linakage setting following has been set Receive

  • Iphone device orientation

    Hi, I am facing strange problem with UIDevice setOrientation method and I will really appreciate if someone could solve this problem. I am navigating between two view controllers thru push and pop. Screen A is list of image series and Screen B displa

  • New iMac (late 2012) and display configuration

    Dear Friends, I have bought the new imac and I need your help configure the space color I wish to use on it. I use a Canon 60D to take photos in RAW (CR2) and it is configurated to use Adobe RGB color space (for both RAW and JPEG). When I checked the

  • K8N Paltinum SLI no surround sound SPDIF not working

    I have a K8N Paltinum SLI. The one with the onboard Soundblaster live! 24 bit. I have this connected througt SPDIF and analog, but only my front speakers work.  I use the Cambridge Soundworks DDT 2500 which is an active decoder. (also from creative)