Skip to Content
avatar image
Former Member

Database connection to MS SQL 2005 (URGENT Help Needed)

Hi all,

Does anyone know how to connect my adobe form to MS SQL 2005?

I have this code:


try {

InitialContext initialContext = new InitialContext ();

DataSource dataSource = (DataSource) initialContext.lookup ("jdbc/MyAlias");

java.sql.Connection connection = dataSource.getConnection ();

} catch (SQLException e) {

// handle exception

} catch (NamingException e) {

// handle exception



Other than these, what else do i need to do inorder to get my database connection up?



And after my database connection is up, how do i test to check if my database connection is up or not?

How do i extract the information from the database and put them onto the textfields/dropdownlists on my form?

Thanks In Advance

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Jan 24, 2008 at 12:49 PM

    Hi Lim,

    You can use the below code for making a database connection and populating the value nodes.

    I have created a view called 'ABC' which has a context with VN called 'FillData' which has VA 'Name', 'Age' & 'Address'.

    //Code for database connection.

    InitialContext ctx = new InitialContext();

    DataSource ds = (DataSource)ctx.lookup("jdbc/AliasName");

    Connection conn = ds.getConnection();

    Statement st = null;

    ResultSet rs = null;

    IPrivateABCView.IFillDataElement dataEle = null;

    st = conn.createStatement();

    //Execute the appropriate SQL query

    rs = st.executeQuery("SELECT NAME,AGE,ADDRESS WHERE SEX='M' ");



    //Code that will populate your VN based on the data obtained in the ResultSet.

    dataEle = wdContext.createFillDataElement();






    Close the connections




    Add the appropriate Try--Catch blocks wherever necessary.

    A simple way to test the connection is to put Message Manager sts before and after the ds.getConnection() code.

    Hope this helps.

    Add comment
    10|10000 characters needed characters exceeded