How to improve jdbc 4 connection and Transact-SQL

I am using a jdbc 4 connection to connect to Database.
With code
Class.forName("org.postgresql.Driver");
String url = "jdbc:msql://athens.imaginary.com:4333/db_web";
username = �mycon�;
password = �mycon�;
Connection  conn = DriverManager.getConnection(url, username, password);And quering and updating with database with TSQL
Sample code
Statement select = con.createStatement();
ResultSet result = select.executeQuery("SELECT key, val FROM t_test"); I am able to get the result
But i want to improve it.
Whether i should use any other api or any other configrational changes I need to imporove the rilibility and increase the speed.
Any suggestions?

Please don't cross-post. You have a thread for this in the JDBC forum (which is where it belongs, if anywhere), so keep the discussion there, please.

Similar Messages

  • I want to Know how to use JDBC connection with postgress sql on Linux

    Hello friends R u Listen to me?
    Pls help me for making JDBC connectivity with postgress Sql On Linux by using Type 4 Driver .
    Is there is any envoirnment setting rqr then pls send me the same on my mail
    My mail is [email protected]
    varsha

    dcminter wrote:
    http://java.sun.com/docs/books/tutorial/jdbc/index.html
    and
    http://www.postgresql.org/docs/
    ;-)

  • How to create JDBC connection in J2ME with MS-SQL server?

    I need to have database connection in PDA with SQL server,as i am new to J2ME ,i dont know how to create jdbc connection on J2ME device.Please help me out with this problem........

    I need to have database connection in PDA with SQL server,as i am new to J2ME ,i dont know how to create jdbc connection on J2ME device.Please help me out with this problem........

  • How to use JDBC Connection Pools in a standalone application?

    Hi, there,
    I have a question about how to use JDBC Connection Pools in an application. I know well about connection pool itself, but I am not quite sure how to keep the pool management object alive all the time to avoid being destroyed by garbage collection.
    for example, at the website: http://www.developer.com/java/other/article.php/626291, there is a simple connection pool implementation. there are three classes:JDBCConnection, the application's gateway to the database; JDBCConnectionImpl, the real class/object to provide connection; and JDBCPool, the management class to manage connection pool composed by JDBCConnectionImpl. JDBCPool is designed by Singleton pattern to make sure only one instance. supposing there is only one client to use connection for many times, I guess it's ok because this client first needs instantiate JDBCPool and JDBCConnectionImpl and then will hold the reference to JDBCPool all the time. but how about many clients want to use this JDBCPool? supposing client1 finishes using JDBCPool and quits, then JDBCPool will be destroyed by garbage collection since there is no reference to it, also all the connections of JDBCConnectionImpl in this pool will be destroyed too. that means the next client needs recreate pool and connections! so my question is that if there is a way to keep pool management instance alive all the time to provide connection to any client at any time. I guess maybe I can set the pool management class as daemon thread to solve this problem, but I am not quite sure. besides, there is some other problems about daemon thread, for example, how to make sure there is only one daemon instance? how to quit it gracefully? because once the whole application quits, the daemon thread also quits by force. in that case, all the connections in the pool won't get chance to close.
    I know there is another solution by JNDI if we develop servlet application. Tomcat provides an easy way to setup JNDI database pooling source that is available to JSP and Servlet. but how about a standalone application? I mean there is no JNDI service provider. it seems a good solution to combine Commons DBCP with JNID or Apache's Naming (http://jakarta.apache.org/commons/dbcp/index.html). but still, I don't know how to keep pool management instance alive all the time. once we create a JNDI enviroment or naming, if it will save in the memory automatically all the time? or we must implement it as a daemon thread?
    any hint will be great apprieciated!
    Sam

    To my knoledge the pool management instance stays alive as long as the pool is alive. What you have to figure out is how to keep a reference to it if you need to later access it.

  • How to set the connection parameters for SQL

    How to set the connection parameters for SQL to access the MS Access database
    Attachments:
    Quick_SQL.vi ‏21 KB
    Doc1.doc ‏45 KB
    db1.mdb ‏112 KB

    Right-click the WINDOWS desktop, choose New->Microsoft Data Link. That will bring up a dialog that allows you to configure and test your database connection. You might connect to the Access database via ODBC or directly via Jet Engine. The Jet Enginge saves you the trouble of creating an ODBC connection on your PC. After you leave the dialog, the "data link" will show up on your desktop as text file. Open it and copy-paste the connection string to your VI.
    This webpage is an excellent resource for connection strings: http://www.able-consulting.com/ADO_Conn.htm
    If your application requires users to change the database connection at runtime, you can also include the dialog via ActiveX (MSDASC.IDataSourceLocator).

  • How to configure JDBC connection in oracle BI publisher with teradata datab

    Hi,
    I am going to use Oracle BI publisher to create report.
    Our database is Teradata.
    How to create database connection for Teradata in BI publisher.
    How to create JDBC connection.
    What should be the Database Driver Class?
    What should be the connection string format?
    Please provide me the suggetion.
    Thanks,
    Santanu Manna

    Hi;
    I suggest please refer below which could be helpful on your issue:
    How To Generate XML Output (Excel, HTML, PDF) for FSG Reports [ID 804913.1]
    E-XMLP: BI Publisher Report RTF Template to Excel output is not same as PDF,RTF or HTML format.[Article ID 1515711.1]
    BI Publisher Enterprise Excel Output File Size is Too Large [ID 1271544.1]
    Regard
    Helios

  • Need help with Thin JDBC connecting Oracle to SQL server.

    I am fairly new to JAVA. We have ORACLE 8.1.7 running on Solaris 8. I have a need to
    periodically extract data from ORACLE DB and transfer it to SQL Server. I am limited to
    moving data from the ORACLE/UNIX environment to SQL Server side.
    From what I have read, Server-side Thin driver should work.
    1) Are there any issues in trying to achieve this with ORACLE running on the UNIX platform?
    2) Will the Server-side Thin driver talk to both the DBs ?
    3) Is it possible to provide some sample code ?
    Thanks in advance,
    Solomon

    Quattro,
    I had complete success in reading from Oracle and writing to SQL Server. First of all let me thank you for all your help. I do have one last request. Its more on optimization than any thing else.
    I was trying to optimize my code by grouping both the connections in one place and to keep my reads and inserts together so that I don't commit at the end of each insert etc. I don't seem to have the scope rules under control yet. Could you suggest how to improve this:
    import java.sql.*;
    public class Test_Combined2 {
    public static void main(String args[]) throws SQLException {
    // Load the Oracle JDBC driver
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    // Connect to the database
    // You must put a database name after the @ sign in the connection URL.
    // You can use either the fully specified SQL*net syntax or a short cut
    // syntax as <host>:<port>:<sid>. The example uses the short cut syntax.
    Connection con2 = DriverManager.getConnection ("jdbc:oracle:thin:@Test:1521:PSDEVElOP",
    "SOLOMON","SOL1");
    // Create a Statement
    Statement stmt2 = con2.createStatement ();
    String url = "jdbc:microsoft:sqlserver://INTRADEV:1433;DatabaseName=Measure";
    Connection con;
    String query = "select dataYear, dataMonth, yieldRate from tblYield " ;
    Statement stmt;
    try {
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    } catch(java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.print(e.getMessage());
    // Select the ENAME column from the EMP table
    ResultSet rset = stmt2.executeQuery ("select year_start, monthofyear, percent_comp " +
    " from ps_usm_ytd_yield ");
    // Iterate through the result and print the employee names
    while (rset.next ()) {
    System.out.println (rset.getFloat (3));
    int ps_dataYear = rset.getInt(1);
    int ps_dataMonth = rset.getInt(2);
    float ps_yieldRate = rset.getFloat(3);
    try{
    con = DriverManager.getConnection (url, "tmpuser","tmppush");
    stmt = con.createStatement();
    PreparedStatement insertTblYield;
    String insertString = "insert into tblYield " +
    " values(?, ?, ?)";
    //con.setAutoCommit(false);
    insertTblYield = con.prepareStatement(insertString);
    insertTblYield.setInt(1, ps_dataYear);
    insertTblYield.setInt(2, ps_dataMonth);
    insertTblYield.setFloat(3, ps_yieldRate);
    insertTblYield.executeUpdate();
    con.commit();
    //con.setAutoCommit(false);
    /*ResultSet rs = stmt.executeQuery(query);
    System.out.println("dataYear, dataMonth, yieldRate");
    while (rs.next()) {
    int dataYear = rs.getInt(1);
    int dataMonth = rs.getInt(2);
    float yieldRate = rs.getFloat(3);
    System.out.println(" " + dataYear + ", " + dataMonth + ", " + yieldRate);
    stmt.close();
    con.close();
    } catch(SQLException ex) {
    System.err.print("SQLException: ");
    System.err.println(ex.getMessage());
    } //while
    stmt2.close();
    con2.close();

  • Configuring RAC-aware JDBC connection in Oracle SQL Developer?

    How can Oracle SQL Developer be configured to properly connect to an [Oracle RAC|http://en.wikipedia.org/wiki/Oracle_RAC] environment, I.E., not just setup to always connect to one of the individual nodes?
    [http://programmersjournal.blogspot.com/2008/08/jdbc-connection-string-for-oracle-rac.html] has an example of a classic and the equivalent RAC-aware version of a JDBC connection string. I've already been using a RAC connection string of the same format from within custom Java applications without issue. I thought the same should be configurable in Oracle SQL Developer by setting the "Connection Type" drop-down to "Advanced", then entering the RAC-aware JDBC connection string as the "Custom JDBC URL". However, upon testing the connection, the following error is displayed at the bottom of the dialog:
    Status : Failure -Test failed: Io exception: NL Exception was generated
    There is no additional information shown on the "Logging Page" view. Using Oracle SQL Developer 1.5.5.
    Thanks!

    Thanks, Barry. Just F.Y.I., it is working for me now that I upgraded to the 2.1 EA as -K- suggested. I had marked his reply as "Correct", but probably should have left a response indicating my success as well.
    Now, if there's anything you could do regarding the [issues around the display performance of CLOBs, etc., in the Query Result view|http://forums.oracle.com/forums/message.jspa?messageID=3906571] , it'd be very appreciated!

  • How to create database connection and how to call it using Java

    Hi,
    Good day! I'd like to know how I can create a db connection in JDev, then use this connection to retrieve data using a Java Class? I've seen using New Gallery > Database Connection. But I'm not sure how I can access this connection using Java and display some output from the retrieved records.
    Any steps/tutorial link is appreciated.
    Thanks in advance,
    Rian

    Hi,
    If you need to access the connection in the entity object then refer http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcadvgen.htm#BABEIFAI i.e in MODEL.
    But if you want to access connection in ViewController part of application then you need to do it manually.For this i am giving you my code for reference.------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import javax.faces.context.FacesContext;
    import oracle.jdbc.pool.OracleDataSource;
    public class DataHandler {
    String jdbcUrl = null;
    String userid = null;
    String password = null;
    Connection conn;
    public static final String CONNECTION_STRING =
    FacesContext.getCurrentInstance().getExternalContext().getInitParameter("connectionString");
    public static final String USER_NAME =
    FacesContext.getCurrentInstance().getExternalContext().getInitParameter("userName");
    public static final String PASSWORD =
    FacesContext.getCurrentInstance().getExternalContext().getInitParameter("password");
    public DataHandler(String jdbcUrl, String userid, String password,
    boolean shouldConnect) throws SQLException {
    this.jdbcUrl = jdbcUrl;
    this.userid = userid;
    this.password = password;
    if (shouldConnect) {
    connect();
    public void connect() throws SQLException {
    OracleDataSource ds;
    ds = new OracleDataSource();
    ds.setURL(jdbcUrl);
    conn = ds.getConnection(userid, password);
    public Connection getConnection() {
    return conn;
    public ResultSet executeQuery(String sql) throws SQLException {
    Statement s = conn.createStatement();
    return s.executeQuery(sql);
    public void closeConnection() throws SQLException {
    if (!conn.isClosed()) {
    conn.close();
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  • JDBC connection to Microsoft SQL Server

    How connect to MS SQL 2000 using JDBC from Oracle(java stored procedure) ?
    I can connect to Oracle jdbc:
    create or replace and compile java source named Hello as
    import oracle.jdbc.driver.OracleDriver;
    (C:\oracle\bise1\db\jdbc\lib\classes12.zip\oracle\jdbc\driver)
    But I don't know how to connect to
    Microsoft sql server?
    sorry answer in
    Re: Querying MS SQL Server from PL/SQL with JDBC
    1)download
    Microsoft SQL Server 2005 JDBC Driver 1.2
    2)C:\oracle9i\bin>loadjava -user scott/tiger sqljdbc.jar
    import com.microsoft.sqlserver.jdbc.SQLServerDriver;

    Hello,
    SQL Server Express will go to sleep if idle, this behavior is not configurable.
    When SQL Express transitions from idle to active some of the memory that was released needs to be reclaimed; this results is a slight lag during "startup time" when you're first connecting to SQL Express.
    The other sort of sleep occurs when a database with AUTO_CLOSE unloading itself after a period of inactivity. This can be resolved by setting AUTO_CLOSE to false.
    You can refer to the following blog about more details about this:
    http://blogs.msdn.com/b/sqlexpress/archive/2008/02/22/sql-express-behaviors-idle-time-resources-usage-auto-close-and-user-instances.aspx
    You can try to upgrade the SQL Server Express to a non-free version to get rid of this.
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • Crystal Reports's JRC. How to close JDBC connection?

    Hi!
    I have simple CR JRC application under Oracle AS 10.1.2.0.2, made from Crystal's sample codes.
    It works fine, but there is little problem: after closing vievwer's page JDBC connections stays alive.
    How can I close them?
    Here is my 2 jsp:
    ---------- Page1.jsp -----------------
    "<%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@page import="com.crystaldecisions.reports.sdk.*" %>
    <%@page import="com.crystaldecisions.sdk.occa.report.lib.*" %>
    <%@page import="com.crystaldecisions.report.web.viewer.*"%>
    <%
    // open the report rpt file
    String REPORT_NAME = "directs_q_d1.rpt";
    String Login =request.getParameter("p1");
    String Password =request.getParameter("p2");
    ReportClientDocument reportClientDoc = new ReportClientDocument();
    reportClientDoc.open(REPORT_NAME, 0);
    reportClientDoc.getDatabaseController().logon(Login,Password);
    ParameterFieldController paramFieldController = reportClientDoc.getDataDefController().getParameterFieldController();
    paramFieldController.setCurrentValue("", "reportname", new String("DIRECTS_QUARTERLY"));
    session.setAttribute("reportSource", reportClientDoc.getReportSource());
    reportClientDoc.close();
    response.sendRedirect("CrystalReportViewer.jsp");
    %>
    and
    ----------- CrystalReportViewer.jsp ------------------------
    <%//Crystal Report Viewer imports.%>
    <%@page import="com.crystaldecisions.report.web.viewer.*"%>
    <%@page import="com.crystaldecisions.reports.sdk.*" %>
    <%
    //Refer to the Viewers SDK in the Java Developer Documentation for more information on using the CrystalReportViewer
    //API.
    CrystalReportViewer viewer = new CrystalReportViewer();
    viewer.setOwnPage(true);
    viewer.setOwnForm(true);
    viewer.setPrintMode(CrPrintMode.ACTIVEX);
    viewer.setHasRefreshButton(false);
    viewer.setEnableDrillDown(false);
    viewer.setDisplayGroupTree(false);
    viewer.setHasToggleGroupTreeButton(false);
    viewer.setHasViewList(false);
    viewer.setHasLogo(false);
    //Get the report source object that this viewer will be displaying.
    Object reportSource = session.getAttribute("reportSource");
    viewer.setReportSource(reportSource);
    //Render the report.
    viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), out);
    viewer.dispose();
    %>
    -------------------------------------

    Oh, i'm sorry :) It was a "time-out" tag in CRconfig.xml. Tipic closed.

  • Newbie: Problem with jdbc-odbc and MS SQL server 2005

    I'm on win vistax64 with SQLSERVER 2005 and I have set up the odbc source as system dsn using the SQL Native Client driver with SQL authentication and the connectivity test in the end succeeds.
    I'm trying to make a simple web app that will connect to the database and perform simple querries. It's a school assignment.
    I'm using the jdbc-odbc bridge because it's the simplest way to do it and it's what we were shown in class.
    I get the following irritating error:
    "Cannot establish a connection to jdbc:odb:sstmdb using sun.jdbc.odbc.JdbcOdbcDriver ([Microsoft][ODBC Driver Manager] Data source name not found and no default driver specifies)".
    I'm working with netbeans 5.5.1 and this error is what I get when in the runtime tab I try to connect with the jdbc-odbc. I get a similar error in the logs when I try to run the app on the j2ee server.
    This is the java class that establishes the connection.
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class Connector {
        private static final String dbUrl="jdbc:odbc:sstmdb";
        private static final String user="kimon";
        private static final String password="jackohara";
        public static Connection getConnection(){
            Connection conn = null;
            try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                conn = DriverManager.getConnection(dbUrl,user,password);
            } catch (SQLException e) {
                e.printStackTrace(); 
            } catch (ClassNotFoundException e) {
                e.printStackTrace(); 
            return conn;
    }It has worked perfectly on my school PC with winXP and MSDE2000.
    What am I missing?

    Ok, help came from an other way where I was inquiring about a different problem:
    Connectivity works fine by using User DSN instead of System DSN for the ODBC source.

  • How to improve client handover and roaming between AP's

    Improving client Handover and roaming between APs
    There are a few standards and methodologies available to use to improve handover of clients between APs. Most are focused on VOIP technologies, but it must always be remembered that we cannot control the client Handover (especially with legacy clients) we can only encourage them. Some Standards and methods work well for some environments and some do not - test the recommendations extensively before implementing in a live Production environment. It must also be noted that all settings take effect immediately once applied, however from a client perspective it might need to re-associate for the changes to take effect client side.
    As with everything else in IT, if a perfect method/solution existed there would only be one - try them all and keep the best.
    The Standards and Definitions
    802.11k
    IEEE 802.11k allows a device to quickly identify nearby APs that are available for roaming. When the signal strength of the current AP weakens and the device needs to roam to a new AP, it will already know the best candidate AP with which to connect to.
    802.11r
    IEEE 802.11r specifies fast Basic Service Set (BSS) transitions between access points by redefining the security key negotiation protocol, allowing both the negotiation and requests for wireless resources to occur in parallel.
    When a device roams from one AP to another on the same network, 802.11r streamlines the authentication process. BSS allows a devices to associate with APs more quickly. Coupled with 802.11k's ability to quickly identify the target AP, BSS's faster association method may enhance application performance.
    Handoff Assist
    The AP monitors the RSSI for every associated client. If the RSSI for a specific client falls below "low-rssi-threshold" and continues to fall for the "rssi-falloff-wait-time", then the AP will send a de-auth to the client. 
    The de-auth is meant to kick the client away from the current AP and get it to re-authenticate to a nearby AP. This will have the effect of helping a client handover between 2 APs.
    BUT (Big But), if the client gets de-authed and takes a while to re-authenticate (if it even does re-authenticate automatically after a de-auth), then this will have the effect of destroying communication instead of helping it -- mostly found with legacy clients. 
    Remove Lower Transmit Rates
    Removing lower transmit rates is a way to promote better roaming, BUT not all clients respond well, or even respond to it. 
    The practice is that the basic rates are a subset of the transmit rates. If you only want to allow speeds 9 and up, you would select only the transmit rates of 9 and up, and the basic rates of 9 and 11. If a legacy client expects the rates of 1 and 2 it will not connect.
    Local Probe Threshold
    Local probe Threshold prevents a client from connecting to an AP with a too low a signal - helps more with initial connection than roaming.
    The local probe threshold parameter is not supposed to force clients to roam as soon as they pass near an access point with a good signal, but rather to NOT hold on to an access point with a weak signal (avoiding sticky clients).
    PMK Caching
    Defined by 802.11i and is a technique available for authentication between a single AP and a station. If a station has authenticated to an AP, roams away from that AP, and comes back, it does not need to perform a full authentication exchange. Only the 802.11i 4-way handshake is performed to establish transient encryption keys.
    Opportunistic Key Caching (OKC)
    Is a similar technique to PMK, but not defined by 802.11i, for authentication between multiple APs in a network where those APs are under common administrative control. An Aruba deployment with multiple APs under the control of a single controller is one such example. Using OKC, a station roaming to any AP in the network will not have to complete a full authentication exchange, but will instead just perform the 4-way handshake to establish transient encryption keys
    Implementation and Configuration
    802.11k
    802.11k is configured in your VAP profile. Tick the option to “Advertise 802.11k”. There after set the Handover Trigger Feature Settings.
    Tick the “Enable Handover Trigger feature” and then set RSSI threshold by specifying the -dBm level at what the hand over trigger should be sent to the client
    802.11r
    802.11r is configured under SSID of your VAP profile. Tick the option to “Advertise 802.11r”
    HandofF Assist
    Station Handoff Assist is enabled in RF Optimization under the RF Management section of AP configuration.
    Tick the “Station Handoff Assist” option to enable it, next set the Low RSSI Threshold – the threshold determines above what level no deauth gets sent
    Lower Transmit Rates
    Transmit rates can be adjusted in the Advanced tab of SSID under your VAP profile.
    Remember that the basic rates are a subset of the transmit rates. If you only want to allow speeds 9 and up, you would select only the transmit rates of 9 and up, and the basic rates of 9 and 11
    Local Probe threshold
    Local Probe threshold can be adjusted in the advanced tab of SSID under your VAP profile.
    Depending on the density of your APs consider values between 20 and 40 -- 40 being aggressive in an AP dense area.
    Deny Broadcast Probes
    Denying Broadcast Probes can cause problems with Roaming especially if the SSID is hidden – leave option disabled.

    Hi, thank you for the helpful guidance.  I have a basic question, if the device roam from one AP to another AP with the same SSID.  Is there a need of re-authentication given a) the network uses EAP based authentication; b) the network uses MAC address authentication.   If there is no need of EAP re-authentication, how the 802.11 keys are moved to the new AP.  Thank you very much if you could help me clarify my thought. 

  • How to fix jdbc connection when  SQLstate 08S01

    I have an application that connects to and insert into a remote database which runs on a server I connect to over the internet. I tested it on local server (localhost) and it works fine, but when I put my server IP (72.52.155.111) or web domain I can' t connect. I'm not sure what should I write instead localhost: webdomain or something else ?
    Java code...
    conn =   DriverManager.getConnection("jdbc:mysql://72.52.155.111:3306/fritaor_apartmani" ,"fritaor_root","10000000");
    ...Error code:
    SQLException: Communications link failure due to underlying exception:
    ** BEGIN NESTED EXCEPTION **
    java.net.SocketException
    MESSAGE: java.net.ConnectException: Connection timed out: connect
    STACKTRACE:
    java.net.SocketException: java.net.ConnectException: Connection timed out: conne
    ct
            at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.ja
    va:156)
            at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
            at com.mysql.jdbc.Connection.createNewIO(Connection.java:2666)
            at com.mysql.jdbc.Connection.<init>(Connection.java:1531)
            at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
    :266)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at Mysql.save(Mysql.java:57)
            at Contact.run(Contact.java:299)
            at Testing.main(Testing.java:21)
    ** END NESTED EXCEPTION **
    Last packet sent to the server was 47 ms ago.
    SQLState: 08S01
    VendorError: 0

    Try to connect to the server in another way (such as telnet). See if you can connect to port 3306. If not, the port is blocked or there's nobody listening (is there a mysql server running on the host?).

  • Jdbc Connection And Crystal Reports

    Hi there;
       A tipical jdbc connection , that i found in my "googles" was something like this;
          PropertyBag connInfoProperties = new PropertyBag();
          connInfoProperties.putBooleanValue("Trusted_Connection", false);
          connInfoProperties.put("PreQEServerName", SERVICE);
          connInfoProperties.put("Server Type", "Oracle Server");
          connInfoProperties.put("Database DLL", "crdb_oracle.dll");
          connInfoProperties.put("ServerName", "");
          connInfoProperties.put("Server", SERVICE);
       And so - one .....
    But What I'm looking for is some thing is about passing one connection aready stabilished ; I mean , I want to prepare my connection envirorment before I pass it to crystal;
    Some thing like this connection "getConnection" result function; how can i pass it into crystal report?
    final class GetConnection {
      /** Uses JNDI and Datasource (preferred style).   */
      static Connection getJNDIConnection(){
        String DATASOURCE_CONTEXT = "java:comp/env/jdbc/blah";
        Connection result = null;
        try {
          Context initialContext = new InitialContext();
          if ( initialContext == null){
            log("JNDI problem. Cannot get InitialContext.");
          DataSource datasource = (DataSource)initialContext.lookup(DATASOURCE_CONTEXT);
          if (datasource != null) {
            result = datasource.getConnection();
          else {
            log("Failed to lookup datasource.");
        catch ( NamingException ex ) {
          log("Cannot get connection: " + ex);
        catch(SQLException ex){
          log("Cannot get connection: " + ex);
        return result;

    //boMainPropertyBag: These hold the attributes of the tables ConnectionInfo object
                PropertyBag boMainPropertyBag = new PropertyBag();
                //boInnerPropertyBag: These hold the attributes for the QE_LogonProperties
                //In the main property bag (boMainPropertyBag)
                PropertyBag boInnerPropertyBag = new PropertyBag();
                //Set the attributes for the boInnerPropertyBag
                boInnerPropertyBag.Add("File Path ", @"C:\CrystalReports\sc.xml");
                boInnerPropertyBag.Add("Internal Connection ID", "{680eee31-a16e-4f48-8efa-8765193dccdd}");
                //Set the attributes for the boMainPropertyBag
                boMainPropertyBag.Add("Database DLL", "crdb_adoplus.dll");
                boMainPropertyBag.Add("QE_DatabaseName", "");
                boMainPropertyBag.Add("QE_DatabaseType", "");
                //Add the QE_LogonProperties we set in the boInnerPropertyBag Object
                boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag);
                boMainPropertyBag.Add("QE_ServerDescription", "NewDataSet");
                boMainPropertyBag.Add("QE_SQLDB", "False");
                boMainPropertyBag.Add("SSO Enabled", "False");
                //Create a new ConnectionInfo object
                CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo boConnectionInfo =
                new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();
                //Pass the database properties to a connection info object
                boConnectionInfo.Attributes = boMainPropertyBag;
                //Set the connection kind
                boConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;
                //*EDIT* Set the User Name and Password if required.
                boConnectionInfo.UserName = "";
                boConnectionInfo.Password = "";
                //Pass the connection information to the table
                boTable.ConnectionInfo = boConnectionInfo;
                //Get the Database Tables Collection for your report
                CrystalDecisions.ReportAppServer.DataDefModel.Tables boTables;
                boTables = rptClientDoc.DatabaseController.Database.Tables;
                //For each table in the report:
                // - Set the Table Name properties.
                // - Set the table location in the report to use the new modified table
                boTable.Name = "Orders";
                boTable.QualifiedName = "Orders";
                boTable.Alias = "Orders";
                rptClientDoc.DatabaseController.SetTableLocation(boTables[0], boTable);
                //Verify the database after adding substituting the new table.
                //To ensure that the table updates properly when adding Command tables or Stored Procedures.
                rptClientDoc.VerifyDatabase();
                MessageBox.Show("Data Source Set", "RAS", MessageBoxButtons.OK, MessageBoxIcon.Information);
    You'll have to adjust for your driver.
    Thank you
    Don

Maybe you are looking for