jdbc connection to ms sql test script

Posted on 2006-04-19
Last Modified: 2012-05-05
I need a program that will test a JDBC connection from a server running Unix on top of Windows Server 2003.

The main goal is try to figure out why I can make a connection, but when I try to run a query I get a 'connection failure' error.

The test program can be very simple.

Let me know if you need more info.

Question by:faclogistics
    LVL 4

    Accepted Solution

    Example below connect to SQL server 2000 with Microsoft SQL Server 2000 driver for JDBC.

    import java.sql.*;

    public class getConnection
            public static void main(String[] args)
                    DB db = new DB();
                    Connection conn=db.dbConnect(


    class DB
            public DB() {}

            public Connection dbConnect(String db_connect_string)
                            Connection conn =
                            return conn;
                    catch (Exception e)
                            return null;

    Hope that the code mentioned above will sort out your query.

    Chetan Sachdeva

    Author Comment

    This is great!
    Thank you!!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    The steps for moving the system databases to a new location are documented in the following technical article: However sometimes after the moving process is finished, though SQL i…
    When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
    Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
    Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now