How do i configure DSN connection to database Programmatically

Hi to all,
Can anybody assist me as how could i configure DSN connection to database Programmatically.
Thanks in advance.
Regards
khiz_eng

Hi DrClap,
Many thanx for your advise, i have also done with MS-Access but now i wnated to have with .csv value, how i am going to have this .I have searched the whole JDBC forum already unable to find for .csv
Please provide me and solve my problem
Thanks in advance.
khiz_eng

Similar Messages

  • Java DSN connection to database

    This code compiles without error and executes as anticipated but does not make the database update...
    public void updateFunctionality(String lastName, int goalsIntScored )
                         String sql = "Update UsersTable Set PlayerGoalsScored= " + goalsIntScored + " Where PlayerLastName= " + lastName + ";
          try
         dbAccessCon.getStatement().execute(sql);
         System.out.println("Data Updated");
         dbAccessCon.disconnect();
         catch ( SQLException e )
         System.out.println( "Error: " + dbAccessCon.getLastError() );
         System.out.println("Record Updated");
         }Can a pair or fresh eyes help me?

    It still won't make the update, it has to be the SQL statement doesn't it?
    I've tried all the ' and " combinations possible and still no luck.
    public void updateFunctionality(String lastName, int goalsIntScored ) throws SQLException
                         String sql = "Update PlayerTable Set PlayerGoalsScored= " + goalsIntScored + " Where  PlayerLastName= ' " + lastName + " '";
         try
              dbAccessCon.getStatement().execute(sql);
              System.out.println("Data Updated");
              dbAccessCon.disconnect();
              dbAccessCon.close();
         catch ( SQLException e )
                              System.out.println( "Error: " + dbAccessCon.getLastError() );
         System.out.println("Record Updated");
         }Here is how I make my DSN connection:
    public boolean connect( String user, String password, String dataBase)
    //     If we are connected, disconnect first!
         if ( isConnected )
              if ( !disconnect() )
              return( false );
    //     Construct a JDBC connection URL
                         String dbUrl = "jdbc:odbc:" + dataBase;
    //     Was there a problem?
                         if ( dbUrl == null )
         return( false );
    //     Try to make a connection...
         try
    //     Make a properties object to pass to the JDBC driver...
              Class myClass = sun.jdbc.odbc.JdbcOdbcDriver.class;
              Properties p = new Properties();
              p.put( "user", user );
              p.put( "password", password );
    //     IDS Connections require a little more...
              myConnection = getConnection( dbUrl, p );
              myStatement = myConnection.createStatement();
                         catch ( SQLException e )
              lastError = e.toString();
              System.out.println( "Error during driver initialization: " + lastError );
              return( false );
    //     It worked!
         isConnected = true;
         System.out.println("isConnected = " + isConnected);
         return( true );
         }I definitely make the disconnection so the SQL has to execute but still no change in the anticipated field.

  • Connect to DataBase programmatically with Integrated Security in SharePoint - which account credentials are used?

    Hi to All!
    I have a simple question. I connect to DataBase programmatically, using SqlConnection and Integrated Security in connection string. It works! But I cannot understand -  which account credentials are used? My Windows account(under which I was logged
    in) or NetworkService Account, or something else?
    If I was logged in as FBA user in SharePoint - what in this case?

    Hi MaryBath,
    When you use integrated security = true it means the same as integrated security = SSPI and in this case the current Windows account credentials are used for authentication and if you set the integrated
    security = false you have to provide UserName and Password . so for your question it uses the current windows account credentials.
    here is the Microsoft link for the same...
    https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(VS.71).aspx
    If your code is executing on server in SharePoint (in webparts or features or application page). it will take the windows account of the server to connect to the database because all are executing on server not on client machine. your
    login credentials has nothing to do with it.
    Note: there are 2 authentication Windows Authentication and SQL Authentication so make sure that on database windows authentication is enabled (it will only work when windows authentication is enabled....
    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

  • How to use datasources to connect to database ?

    I have the following Problem
    I have two identical databases, one is the development database, the other one the production database.
    Now I need to find a way, how I can deploy an bc4j-application in local mode that way, that if the application is deployed to server 1 it connects to database 1 and if deployed to server 2 it connects to database 2.
    JDBC connection strings do not work as the connection is deployed with the application. So the application always connects to the same database.
    I thought datasources might be the solution. So I tried to define a datasource MyDS in the data-sources.xml file and specified it in the Configuration Wizard as the connection to use.
    But unfortunately this does not work and i do not know why:
    If I try to connect using the tester and using this datasource I get the following exception:
    Level #3: javax.naming.noInitialContextException
    Can anyone help me, what this means? How can I get around this using the BC4J Framework? Is there any "HowTo" Document which describes using datasources with BC4J?

    Frank,
    I've sorted this stuff out to some extent. Have a look at this thread:
    re:? How: multiple myAppWar.ear to use OC4J's data-sources.xml pooling?
    If this isn't all you need, then search on data-source.xml
    and read other threads also I may have posted helps on
    other threads so if you search on data-source.xml and my handle (curt504) it brings up all the threads that I posted to.
    Not to say I've solved all your problems, but I solved mine anyway. :)
    Good luck,
    curt

  • How to read the RD Connect Broker DataBase!!!!

    The msdn say there is a RD Connect Broker Data Base , it store the session information,but i dont know where is it and how to read it !
    Thank you !!!!

    Hi,
    You can use the vbs script below to dump the contents of the RD Connection Broker database.
    With credits to the authors of the Windows Server 2008 R2 RDS Resource Kit for putting it in there!
    ' Copyright (c) 2004-2005 Microsoft Corporation
    ' WMI Script - SDDatabaseDump.vbs
    ' Author     - GopiV
    ' This script dumps the contents (clusters and associated sessions)
    ' of the Session Directory database
    ' USAGE: Cscript.exe SDDatabaseDump.vbs <SBservername> <Administrator> <Password>
    const TAB = "    "
    const LINESEPARATOR = "------------------------------------------------"
    ON ERROR RESUME NEXT
    '* Function blnConnect()
    '* Purpose: Connects to machine strServer.
    '* Input:   strServer       a machine name
    '*          strNameSpace    a namespace
    '*          strUserName     name of the current user
    '*          strPassword     password of the current user
    '* Output:  objService is returned  as a service object.
    Function blnConnect(objService, strServer, strNameSpace, strUserName, strPassword)
        ON ERROR RESUME NEXT
        Dim objLocator
        blnConnect = True     'There is no error.
        ' Create Locator object to connect to remote CIM object manager
        Set objLocator = CreateObject("WbemScripting.SWbemLocator")
        if Err.Number then
            Wscript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred in creating a locator object."
            if Err.Description <> "" then
                Wscript.Echo "Error description: " & Err.Description & "."
            end if
            Err.Clear
            blnConnect = False     'An error occurred
            Exit Function
        end if
        ' Connect to the namespace which is either local or remote
        Set objService = objLocator.ConnectServer (strServer, strNameSpace, strUserName, strPassword)
     if Err.Number then
            Wscript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred in connecting to server " _
                & strServer & "."
            if Err.Description <> "" then
                Wscript.Echo "Error description: " & Err.Description & "."
            end if
            Err.Clear
            blnConnect = False     'An error occurred
        end if
        objService.Security_.impersonationlevel = 3
        if Err.Number then
            Wscript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred in setting impersonation level " _
                & strServer & "."
            if Err.Description <> "" then
                Wscript.Echo "Error description: " & Err.Description & "."
            end if
            Err.Clear
            blnConnect = False     'An error occurred
        end if
    end Function 
    ' Start of script
    if Wscript.arguments.count<3 then
       Wscript.echo "Script can't run without 3 arguments: ServerName Domain\UserName Password "
       Wscript.quit
    end if
    Dim strServer, strUserName, strPassword
    Dim objService, blnResult
    ' Extract the command line arguments
    strServer=Wscript.arguments.Item(0)
    strUserName=Wscript.arguments.Item(1)
    strPassword=Wscript.arguments.Item(2)
    ' Connect to the WMI service on the SD Server machine
    blnResult = blnConnect( objService, strServer, "root/cimv2", strUserName, strPassword )
    if not blnResult then
       Wscript.echo "Can not connect to the server " & strServer & " with the given credentials."
       WScript.Quit
    end if
    Set clusterEnumerator = objService.InstancesOf ("Win32_SessionDirectoryCluster")
    if Err.Number then
        Wscript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred"
    end if
    if clusterEnumerator.Count = 0 then
        Wscript.Echo "No clusters found in Session Directory database on " & strServer & "."
        Wscript.Echo
        Wscript.Quit
    end if
    for each clusterObj in clusterEnumerator
        WScript.Echo LINESEPARATOR
        WScript.Echo "ClusterName = " & clusterObj.ClusterName
        WScript.Echo "NumberOfServers = " & clusterObj.NumberOfServers 
        WScript.Echo "SingleSessionMode = " & clusterObj.SingleSessionMode
        Wscript.Echo
        set serverEnumerator = objService.ExecQuery("Select * from Win32_SessionDirectoryServer where ClusterName = '" & clusterObj.ClusterName & "'")
        if Err.Number then
           Wscript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred"
        end if
        if serverEnumerator.Count = 0 then
             Wscript.Echo "Error : No servers in cluster " & clusterObj.ClusterName
             Wscript.Echo
        else
             ' Enumerate the servers in this cluster
             for each serverObj in serverEnumerator
                WScript.Echo TAB & "SERVER :"
                WScript.Echo TAB & "ServerName = " & serverObj.ServerName & " ServerSingleSessionMode = " & serverObj.SingleSessionMode & " LoadIndicator = " & serverObj.LoadIndicator
    '            WScript.Echo TAB & "ServerIP = " & serverObj.ServerIPAddress
      '  WScript.Echo TAB & "ServerWeight = " & serverObj.ServerWeight
                set sessionEnumerator = objService.ExecQuery("Select * from Win32_SessionDirectorySession where ServerName = '" & serverObj.ServerName  & "'")
                if Err.Number then
                   Wscript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred"
                end if  
                if sessionEnumerator.Count = 0 then
                   WScript.Echo
                   WScript.Echo TAB & "No sessions on server " & serverObj.ServerName
                   WScript.Echo
                else
                   WScript.Echo TAB & "NumberOfSessions = " & sessionEnumerator.Count
                   Wscript.Echo
                   ' Enumerate the sessions on this server
                   for each sessionObj in sessionEnumerator
                      WScript.Echo TAB & TAB & "SESSION :"
                      WScript.Echo TAB & TAB & "UserName= " & sessionObj.DomainName & "\" & sessionObj.UserName & TAB & "ApplicationType= " & sessionObj.ApplicationType
    & TAB & "SessionState= " & sessionObj.SessionState
                      WScript.Echo TAB & TAB & "CreateTime= " & sessionObj.CreateTime & TAB & "DisconnectTime= " & sessionObj.DisconnectTime
    '                  WScript.Echo TAB & TAB & "ServerName= " & sessionObj.ServerName
    '                  WScript.Echo TAB & TAB & "SessionID= " & sessionObj.SessionID
    '                  WScript.Echo TAB & TAB & "ServerIP= " & sessionObj.ServerIPAddress
    '                  WScript.Echo TAB & TAB & "TSProtocol= " & sessionObj.TSProtocol 
     '                 WScript.Echo TAB & TAB & "ResolutionWidth= " & sessionObj.ResolutionWidth
      '               WScript.Echo TAB & TAB & "ResolutionHeight= " & sessionObj.ResolutionHeight
       '             WScript.Echo TAB & TAB & "ColorDepth= " & sessionObj.ColorDepth
        '              WScript.Echo
                      WScript.Echo
                   next
                end if   ' End of sessions on this server
             next
        end if  ' End of servers on this cluster
    next
    Wscript.Echo
    Wscript.Echo
    Wscript.Echo "Dump of SD database on " & strServer & " complete."
    Kind regards,
    Freek Berson
    http://www.microsoftplatform.blogspot.com
    Wortell company website

  • How to i get the connect to database with OLAP API 9.2.0.0

    hi all,
    when i use the OLAP API (9.2.0..0) to connect the database,i gained the message of the following:
    java.lang.NoClassDefFoundError: com/sun/java/util/collections/HashMap
    void oracle.express.olapi.transaction.ExpressTransactionProvider.<init>()          ExpressTransactionProvider.java:40
         void mypackage3.APPEX.init()
              APPEX.java:51
         void sun.applet.AppletPanel.run()
              AppletPanel.java:344
         void java.lang.Thread.run()
              Thread.java:484
    JDev=9.0.3
    OLAP API=9.2.0.0
    Oracle 9i 9.2.0.1
    and how can i get the OLAP API 9.2.0.4.1?
    anyone can help me !
    thanks!!!

    Hi, yes, there are at least two known ways:
    1. if you happen to have a UCCX premium, you can create an HTTP application that serves up the prompt file,
    2. you can try to access the prompt file like this: http://<uccxip>:9080/prompts/dirname/promptfilename.wav
    G.

  • How to use JDBC to connect informix database

    Dear all,
    I want my client application to connect informix database by using JDBC. The JDBC driver has been installed successfully in the client computer (Win2000). The informix 5.0 resides the a Unix server named "dbserver". The following is my java program.
    ========================
    import java.sql.*;
    import java.awt.event.*;
    public class Application1 {
    public static void main(String[] args) {
    Connection conn;
    try
    Class.forName("com.informix.jdbc.IfxDriver");
    catch (Exception e)
    System.out.println("Error "+e.getmessage());
    e.printStackTrace();
    return;
    System.out.println("It is ok");
    try
    conn = DriverManager.getConnection("jdbc:informix-sqli://dbserver:1526:INFORMIXSERVER=dbserver;username=test;password=******");
    catch (SQLException e)
    System.out.println("ERROR ."+e.getMessage());
    e.printStackTrace();
    return;
    System.out.println("All is fine");
    ===========================
    However, the error appears mentioning "Attempt to connect to database server (dbserver) failed." I don't know what the problem is because my informix database server is exactly "dbserver".
    Kindly need help from you guys. Thanks in advance.
    Kevin

    Hi,
    Plz try this (instead of 'username' use 'user') ...
    DriverManager.getConnection("jdbc:informix-sqli://dbserer:1526:INFORMIXSERVER=dbserver;user=test;password=*****");
    or this (pass the username and password as params)....
    DriverManager.getConnection( "jdbc:informix-sqli://dbserer:1526:INFORMIXSERVER=dbserver" , "test" , "*****" );
    Hope this helps
    ssa.
    >
    I want my client application to connect informix
    database by using JDBC. The JDBC driver has been
    installed successfully in the client computer
    (Win2000). The informix 5.0 resides the a Unix server
    named "dbserver". The following is my java program.
    ========================
    import java.sql.*;
    import java.awt.event.*;
    public class Application1 {
    public static void main(String[] args) {
    Connection conn;
    try
    Class.forName("com.informix.jdbc.IfxDriver");
    catch (Exception e)
    System.out.println("Error "+e.getmessage());
    e.printStackTrace();
    return;
    System.out.println("It is ok");
    try
    conn =
    onn =
    DriverManager.getConnection("jdbc:informix-sqli://dbser
    er:1526:INFORMIXSERVER=dbserver;username=test;password=
    catch (SQLException e)
    System.out.println("ERROR ."+e.getMessage());
    e.printStackTrace();
    return;
    System.out.println("All is fine");
    ===========================
    However, the error appears mentioning "Attempt to
    connect to database server (dbserver) failed." I don't
    know what the problem is because my informix database
    server is exactly "dbserver".
    Kindly need help from you guys. Thanks in advance.
    Kevin

  • How To make/configure  Broadband connection in Sun java desktop system

    Hi all,
    I am using sun java desktop system Release 3 solaris 10 version in my sun ultra workstation. I have a problem with it. I can not make broadband connection , in it. so pls let me know how can i make broadband connection with my ADSL modem ?
    Thanks
    Partha

    Try this:
    Log into a termina as rootl. (Select failsafe terminal or command login)
    To get the name of your network interface driver, type:
    /usr/sbin/ifconfig -a You'll see something like this:
    lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
    inet 127.0.0.1 netmask ff000000
    hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
    inet 129.156.226.245 netmask ffffff00 broadcast 129.156.226.255
    In my case it is hme0 so I create a file called /etc/dhcp.hme0:
    touch /etc/dhcp.hme0If you want to set a hostname, put it in a file called /etc/hostname.hme0 for example:
    rm /etc/hostname.hme0
    echo myhostname > /etc/hostname.hme0Most broadband providers preconfigure ADSL modems to default to DHCP so if you do this, connect the ultra 10 to the broadband modem and reboot, the ultra 10 should pick up an IP address and be connected to the internet.

  • How to create odbc (dsn) connection for OBIEE AND INFOR in unix environment

    Hi,
    we are establishing OBIA in Unix environment we set all the things fine but we are getting problem how to create ODBC connection
    for INFORMATICA AND OBIEE. I searched some blogs thats telling there is a ODBC.INI file we need to configure.
    but i am not getting clear idea to give parameters and it will not showing any TNSNAME ..........etc
    please any body give clear idea about how to create ODBC connection and LOCATION of that file AND parameter which i need to give.
    Thanks,
    charan....

    Hi Dpka,
    yah i already checked that one but i have not find out any parameter for TNS NAME information.
    is OBIEE connected to ORACLE DATA BASE without giving TNS information?............in UNIX OPERATING SYSTEM.
    pls give me the clear idea abt how to connect OBIEE, INFORMATICA to ORACLE DATA BASE IN UNIX ENVRNMENT
    thanks,
    charan.

  • How make the condition to connect correct database in mySQL or Java bean

    Is there can make a seting so when make a query to database.
    In my database enviroment, it consist of share database and individual database.
    If that individual database doesn't have that table specific in the query, it will search default database for that table.
    The sql statement may have combination of share database and individual database.
    Is it posible?

    try{
      //connect to db1
      //execute query
    }catch(SQLException e){
      if(e.getMessage().indexOf("Table table doesn't exist")>-1){
        try{
           // close connection if open
           //connect to default db
         }catch(SQLException ex){
           ex.printStackTrace();       
    }

  • How to find # of sessions connected to database between a specific time?

    Hi guys,
    My database is 10.2.0.2 on a four node RAC Cluster. OS is RHEL4.
    I was watching total # of session (without system processes) on 9/24/08 at 9AM (from gv$session view) and total sessions across all four nodes were little over 1600. Following was the query I was using to count #of sessions.
    select s.inst_id, count(*) from gv$session s
    where s.username is not null
    and s.username not in ('SYS', 'SYSTEM', 'DBSNMP', 'SYSMAN')
    group by rollup (s.inst_id);
    Now after few days, when I check the distinct session_id connections using dba_hist_active_sess_history between 9:00 and 9:10 AM, I get lot less count on session_id, little less than 1000. I was expecting same or higher count than original 1600+ since I am giving 10 min time interval.
    Following is the query, I am using:
    select instance_number, count(distinct session_id) from dba_hist_active_sess_history
    where sample_time between
    to_timestamp('2008-09-24 09:00:00','YYYY-MM-DD HH24:MI:SS') and
    to_timestamp('2008-09-24 09:10:00','YYYY-MM-DD HH24:MI:SS')
    group by instance_number;
    Am I doing something wrong? Is there any other v$ view or any other sysaux repository table I can view to collect total # of session (with or without background processes) between 9:00AM and 9:10AM on 9/24/08?
    Thank you,
    --MM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Thank you, Satish. Is there any way we can get the total # of session counts (including idle) from, lets say, two days ago?
    --MM                                                                                                                                                                                                                                                                       

  • 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;

  • How to connect oracle database from solaris platform

    I have installed oracle9i client on solaris8, how can I configure to connect other oracle database?
    thanks for your assistance!!

    If the database is remote you would need to setup a sqlnet.ora and a tnsnames.ora file. Their locations are platform dependent. On AIX the files are in /etc while on some platforms you find the files in /var/opt/oracle and on others $ORACLE_HOME/network/admin. We have a Sun Sparc running SunOS 5.6 that has them in /var/opt/oracle.
    Configuation can be done through the installer as part of the install process, probably using a gui tool, or manually. We vote for manually.
    See your install README files and the ORANET manuals for details. Or once you know where the files belong copy them from a platform that can access the db you want to reach and just remove unnecessary lines for other databases.
    HTH -- Mark D Powell --

  • 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!

  • How can I use File DSN to connect to database?

    Hi,
    I am using ODBC-jdbc driver to connect to the database. It seems that the DSN name is required. How can I use a file DSN instead of system DSN to connect to database? Please help?

    oracle provided jdbc drivers (thin and oci) do not use odbc.
    why would you want to slow things down by sending "round trip" data transfers thru a "jdbc to odbc" and thru "odbc to jdbc" conversion routines.
    It isn't necessary with the oracle provided drivers !!

Maybe you are looking for

  • Transfering Library from XP to Vista

    I have multiple libraries on XP via Windows login (four total). I purchased a notebook with Vista and new iTunes allowing multiple libraries. I want to transfer these libraries to Vista either retaining them, or creating only one library, any thought

  • I cannot connect to my iMac or my Mackbook from my Windows 7 PC after installing Lion. Worked fine with Snow Leopard

    I have a 2009 iMac and a mid 2007 Macbook. I also have an HTPC running Windows 7. I can connect fine to the HTPC from either the iMac or the Macbook, however, I am completely unable to connect to my Macbook or iMac from my PC. This was never a proble

  • Signing entire portfolios

    The portfolio of Acrobat Pro / ext can handle multiple file formats. I try to sign a whole portfolio with diffrent file types but the the Advanced>sign & certify is greyed-out. However it is possible to encrypt the portfolio which is on the same subj

  • Linux Oracle RAC Issues with CRS

    Using the Linux Oracle RAC install guide - I've finally installed my install on Linux for the Oracle RAC. Just one problem - now after 10 mins or so - one of my nodes loses communication which barks out a PRKH-1010 error after trying to run a status

  • Disappearing EDGE Settings

    OK, this is weird. I have an 8GB, bought in the UK with an 02 plan set up to roam. When I went abroad, I turn the phone off on the pane, then when I turn it back on, the EDGE settings have disappeared. I contacted 02 and got the detail which I loaded