cancel
Showing results for 
Search instead for 
Did you mean: 

Database connection to MS SQL 2005 (URGENT Help Needed)

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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' ");

while(rs.next())

{

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

dataEle = wdContext.createFillDataElement();

dataEle.setName(rs.getString(1));

dataEle.setAge(rs.getInt(2));

dataEle.setAddress(rs.getString(3));

wdContext.nodeFillData.addElement(dataEle);

}

Close the connections

rs.close();

st.close();

conn.close();

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.

Former Member
0 Kudos

Hi Mel,

Thanks alot for your codes =D

I shall go try it now, if it works 10points!! hahaha =DD thanks thanks.. =DD

Former Member
0 Kudos

Hi Mel,

After implementing the codes and modifying them, some of them are underlined, why is this so? =X

Or are u willing to exchange msn so i could send u the screenshot instead?

Thanks In Advance

(Sorry im not that good in this)

(I shall underline the areas which represents the red underline in my web dynpro)

//Code for database connection.

InitialContext ctx = new InitialContext();

DataSource ds = (DataSource)_ctx.lookup("jdbc/JXDataSource");_

Connection conn = ds.getConnection();

Statement st = null;

ResultSet rs = null;

IPrivateDetailed_Claims_FormView.IFillDataElement dataEle = null;

st = conn.createStatement();

// Execute the appropriate SQL query

rs = st.executeQuery("SELECT NAME WHERE VENDORCODE='9000116L' ");_

while (rs.next()) {

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

dataEle = wdContext.createFillDataElement();

dataEle.setName(_rs.getString(1)_);

// dataEle.setAge(rs.getInt(2));

// dataEle.setAddress(rs.getString(3));

//wdContext.nodeFillData.addElement(dataEle);

}

// Close the connections

rs.close();

st.close();

conn.close();

Edited by: JingXuan Lim on Jan 25, 2008 4:59 AM

Edited by: JingXuan Lim on Jan 25, 2008 5:00 AM

Former Member
0 Kudos

oopz i forgot to implement the try catch, sry, its ok now.. juz gotta test the connection..

Will confirm that again later >_<"

Former Member
0 Kudos

Hi Mel,

Ok, after i deploy my project, i receive this '500 Internal Server Error', it stats that:

' com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: Bound data node Node(Detailed_Claims_FormView.FillData) of InteractiveForm must not be empty! '

But i implemented the codes and set the dpfSource and dataSource already, why am i receiving this error message?

Former Member
0 Kudos

Hi Lim,

The error states that the node 'FillData' is empty at runtime.

Try changing the cardinality of the node from 0..n to 1..n.

Hope this helps.

Former Member
0 Kudos

oh wow..ok can deploy already, but when i drag the Name field onto my form it doesnt display anything.. haha.. i think im really such an idiot at this..

Former Member
0 Kudos

Hi Lim.

Can you provide more details as to what the display problem is?

You need to check what type of data is getting populated in the name field and whether it is getting populated or not.

Also the field will get populated at runtime, so i din't quite understand about the dragging part.

Is it when you are dragging from the Data View in the left hand side of the Adobe Designer View to the Body page of the form ?

If you can provide me with complete details it would be great

Former Member
0 Kudos

Hi Mel,

Thanks for replying me 😃

I'll check it tml, as im not in school and do not have SAP Netweaver at home..

Will post a reply tml (Monday)

Thanks In Advance 😃

Former Member
0 Kudos

Hi Mel,

I want need to pre-fill my form, and the fields required to be pre-filled is more than 1 data type, but for now, im trying to get my form to pre-fill a 'text field'.

Firstly i created a new data node and attribute as u have mentioned previously, then inplemented the codes, then in my 'Data View' tab, i can see the context i created, i drag the '@Name' onto my form and previews it, but nothing happens. Is there anything else that i left out? or anymore codes that needs to be implemented.

-


Oh, and wad are the .JAR files required for MS SQL 2005?

I have mssqlserver.jar / msbase.jar / msutil.jar in my visual admin, but these 3 from what i know is for MS SQL 2000, are these JAR files sufficient for MS SQL 2005? or do i need to install any other JAR files?

-


Mel,

Is it possible for me to have ur e-mail? or i give u my e-mail? Or do u have a msn account? This is my last week to complete this project, and i'm really rushing it through, would be great if its possible for an alternative communication method.. Thanks.. >_<

Edited by: JingXuan Lim on Jan 28, 2008 3:03 AM

Former Member
0 Kudos

Hi Lim,

The data that you are trying to view for the Name field will NOT appear in the Preview mode. You need to deploy and run your application and only then the data will appear in the Name field at runtime.

If you are using a Web Dynpro for Java application to display the pre-filled form you need to place the code in the wdDoInit() of the View in which you have used the Interactive Form element.

-


In regards to the .JAR files i am not quite sure which one's are required.

-


If you have any queries, you can contact me on :

Melwyn.Monis@lntinfotech.com

Cheers.

Former Member
0 Kudos

Hi Mel,

I gave u 10points and sent u an e-mail, hope u can reply me asap thx =D

Answers (0)