cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in connecting sql server database*urgent*

Former Member
0 Kudos

Good afternoon,

I need to do an application that allow user to search for his employees ID and when the server found his employees ID , it will show NAME and his particular from the SQL database at the adobe interactive form.

I recently found this thread regarding how to connect Connect to sql server database from webdynpro with jdbc 2.0 driver ()

I tired and these is what i put in VA:

In the screen that appears, under the “main” tab:

1) DataSource Name =MyDataSource

2) Add Alias = MyAlias.

3) Driver Name=SQL Server

4) JDBC Version= select “2.0 (with XA support)”

5) Object Factor = “com.microsoft.jdbcx.sqlserver.SQLServerDataSourceFactory”.

Please omit the quotes.

6) DataSource Type =“ConnectionPoolDataSource”

7) CPDS classname = “com.microsoft.jdbcx.sqlserver.SQLServerDataSource”.

Under Additional tab. Under the additional properties section, type in:

1) Key: serverName, Value: Localhost

2) Key: databaseName, Value: “CSIT”

3) Key: portNumber, value: “ 1433”

4) Key: user, value: admin

5) Key: password, value: ********

6) For SQL Engine, Select Vendor SQL

As for back code at web dynpro (implementation part)

<u><b>I insert these code at my onActionSearch buttom</b></u>

public void onActionSearch(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionSearch(ServerEvent)
    IPrivateInvoiceSummary.IInvoiceDetailElement element =wdContext.createInvoiceDetailElement();
    	
			try{
			   Context ctx = new InitialContext();
			   DataSource ds = (DataSource)ctx.lookup("jdbc/MyAlias");	
	
			   Connection con=ds.getConnection();
			   Statement  st=con.createStatement();
		   
			   ResultSet rs = st.executeQuery("SELECT * FROM InvoiceDetailForm WHERE PVNo= '"+wdContext.currentContextElement().getSearchNo()+"';");
			   while(rs.next()){
			   	
				element.setPVNo(rs.getString("PVNo"));
				element.setPVDate(rs.getString("PVDate"));
				element.setRefNo(rs.getString("RefNo"));
				element.setSection(rs.getString("Section"));
			   }
		   
			   wdContext.nodeInvoiceDetail().bind(element);
		   
			} catch (Exception e)
			{
				wdComponentAPI.getMessageManager().reportWarning(e.toString());
			}
    //@@end
  }

I tired to deploy and run the application, it show everything (My textfield, search button and adobe form).

When i key in employees ID and click search , it prom me that the IE has encountered a problem and needs to close.

May i know the reason behind it?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Element need to be created for each record

IPrivateInvoiceSummary.IInvoiceDetailElement element =wdContext.createInvoiceDetailElement();

above line should be inside the while loop.

you can replace that with createandaddElement.

and remove the following code

wdContext.nodeInvoiceDetail().bind(element);

Regards

Ayyapparaj

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi Mithu,

Create the class path and path at System variables.

However, when i deploy my web dynpro , it prom me

500 Internal Server Error where

Failed to process request. Please contact your system administrator.

[Hide]

Error Summary

While processing the current request, an exception occured which could not be handled by the application or the framework.

If the information contained on this page doesn't help you to find and correct the cause of the problem, please contact your system administrator. To facilitate analysis of the problem, keep a copy of this error page. Hint: Most browsers allow to select all content, copy it and then paste it into an empty document (e.g. email or simple text file).

Root Cause

The initial exception that caused the request to fail, was:

com.sap.tc.webdynpro.clientserver.adobe.pdfdocument.base.core.PDFDocumentRuntimeException: Severe : PDFDocument is NULL. Exception : Service call exception; nested exception is: java.net.SocketTimeoutException: Read timed out

at com.sap.tc.webdynpro.clientserver.uielib.adobe.impl.InteractiveForm.afterHandleActionEvent(InteractiveForm.java:385)

at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.afterApplicationModification(ClientApplication.java:1117)

at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.afterApplicationModification(ClientComponent.java:887)

at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doRespond(WindowPhaseModel.java:573)

at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:152)

... 25 more

and server still deploy

Server

Web Dynpro Runtime Vendor: SAP, build ID: 7.0007.20060509173555.0000 (release=NW04S_07_REL, buildtime=2006-05-09:16:21:23[UTC], changelist=13857, host=pwdfm114), build date: Tue Sep 04 19:43:33 GMT+08:00 2007

J2EE Engine No information available

<u><b>Java VM Java HotSpot(TM) Server VM, version:1.4.2_14-b05, vendor: Sun</b></u> Microsystems Inc.

Operating system Windows XP, version: 5.1, architecture: x86

i don't know why it still using version 1.4.2_14

do you know the reason behind it?

Former Member
0 Kudos

i tried down grade j2sdk is 1.4.2_14 to j2sdk is 1.4.2_12 but the problem still not solve..

Is it there's something wrong in my configuring ?

My step for configuring is :

Web dynpro:

1) when to windows

2) preferences

3) Choose Java

4)then Installed JRES

5) Then choose jdk1.4.2_12

under window control panel is :

1)Go to system

2) Advanced

3) Under Enviroment

4) then create Java_Home for variable name and C:\j2sdk1.4.2_12 for variable value

under user variables .

5) then create Java_Home for variable name and C:\j2sdk1.4.2_12 for variable value

under system variables.

After All these , i went to CMD to check for version and it change to

java version "1.4.2_12"

java 2 Runtime Environment , standard edition (build 1.4.2_12-b03)

java hotSpot client VM (build 1.4.2_12-b03, mixed mode)

Does any one know the solution for this? I really need to solve it ..... I don't know issit my database coding got error or my system got the problem....

thanks .....marks will bve given

former_member751941
Active Contributor
0 Kudos

Hi Weilin,

Under Environment Variable.

Edit System variables.

<b>CLASSPATH</b> the add

C:\j2sdk1.4.2_09\bin;C:\j2sdk1.4.2_09\lib;C:\j2sdk1.4.2_09\jre\lib;

Click on OK.

and <b> Path</b>

C:\j2sdk1.4.2_09\bin;C:\j2sdk1.4.2_09\jre\bin;C:\j2sdk1.4.2_09\lib;

Click on OK. Then try.

Regards,

Mithu

Former Member
0 Kudos

Hi Anant ,

i tried fire fox before but unable to show PDF. However, i downgrade IE 7 to IE 6 , it show PDF, just that when i click search botton , it keep prom me internet browser need to be close.

My jsdk version is 1.4.2._14 so which jsdk version you recommand is better?

wait forward for your reply

Former Member
0 Kudos

Recommended Sun Microsystems J2SE SDK version 1.4.2_08 or 1.4.2_09

Former Member
0 Kudos

Hi Akshaya,

thanks for your reply, your reply is very helpful to me but the solution that the threat post i have tired and still the same problem occur.

thank you for ur reply!= D

Former Member
0 Kudos

Try using FireFox for change. Also check your jdk version.

Former Member
0 Kudos

Hi murtuza and mithu,

Thanks for your reply and i believe your answer will help me. However , due to the internet problem , i unable to find out whether my adobe forms able to get data using the method you wrote in this threat. Once i settle my problem (refering internet problem), i will try out the code you wrote and once successful try out , i will reward points for both of you.

once again thank you very much 😃

Former Member
0 Kudos

Hi

May be JDBC version is incompatible with webdynpro application.

Check out this thread

/message/4044695#4044695 [original link is broken]

Regards

Akshaya

Former Member
0 Kudos

Hi Ayyapparaj ,

thanks for replying my post , however, it did not solve my problem. Although i change the code as what you say, the IE still close when i click search for employees ID.

Do you know the main reason behind it?

Former Member
0 Kudos

Hi,

Try this:

public void onActionSearch(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionSearch(ServerEvent)

<b> IPrivateInvoiceSummary.IInvoiceDetailElement element =null; </b>

try{

Context ctx = new InitialContext();

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

Connection con=ds.getConnection();

Statement st=con.createStatement();

ResultSet rs = st.executeQuery("SELECT * FROM InvoiceDetailForm WHERE PVNo= '"wdContext.currentContextElement().getSearchNo()"';");

while(rs.next()){

<b>element = wdContext.createInvoiceDetailElement();</b>

element.setPVNo(rs.getString("PVNo"));

element.setPVDate(rs.getString("PVDate"));

element.setRefNo(rs.getString("RefNo"));

element.setSection(rs.getString("Section"));

}

<b> // wdContext.nodeInvoiceDetail().bind(element);

wdContext.nodeInvoiceDetail().addElement(element);</b>

} catch (Exception e)

{

wdComponentAPI.getMessageManager().reportWarning(e.toString());

}

//@@end

}

Regards,

Murtuza

former_member751941
Active Contributor
0 Kudos

Hi Weilin,

After fetching the record close result set, connection and data source

while(rs.next()){

IPrivateInvoiceSummary.IInvoiceDetailElement element =wdContext.createInvoiceDetailElement();

element.setPVNo(rs.getString("PVNo"));

element.setPVDate(rs.getString("PVDate"));

element.setRefNo(rs.getString("RefNo"));

element.setSection(rs.getString("Section"));

wdContext.nodeInvoiceDetail().add(element);

}

rs.close();

con.close();

ds.close();

Regards,

Mithu