cancel
Showing results for 
Search instead for 
Did you mean: 

Database connection in a WebDynpro Application - urgent

Former Member
0 Kudos

Hi

I am facing a problem with database connection. I am trying to develop a normal webdynpro application.

I want to retrieve data from a table and show it.

But my query is not giving the expected output. It is not even raising errors.

Please give me an answer

Thanks & regards

Aparnna

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Thank u

Former Member
0 Kudos
Former Member
0 Kudos

Connection con=null;

Statement st=null;

ResultSet rs=null;

public void wdDoInit()

{

//@@begin wdDoInit()

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con = DriverManager.getConnection("jdbc:odbc:erdsn","root","enteg123");

st=con.createStatement();

}

catch(Exception e){

}

//@@end

}

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

{

//@@begin onActiononClickLogin(ServerEvent)

String desig=null;

try{

rs = st.executeQuery("select * from Login where Empid like uid and Pword like pw");

if(rs.next()){

desig=rs.getString("Designation");

wdComponentAPI.getComponent().getMessageManager().reportSuccess(desig);

if(desig.equalsIgnoreCase("Employee")){

wdThis.wdFirePlugEmpOutPlug();

}

else

{

wdComponentAPI.getComponent().getMessageManager().reportWarning("Invalid input!");

}

}catch(Exception e){

}

}

Former Member
0 Kudos

Hi Aparna,

Please post code so that we can see what went wrong.

try following

try{

Context ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup("jdbc/<<DatasourceName in VisualAdmin>>");

con = ds.getConnection();

Statement st=con.createStatement();

ResultSet rs=st.executeQuery("select * from TABLENAME");

}

catch(Exception e){}

You need to configure Datasource in the visualadminstrator ->services->jdbc

Regards, Anilkumar

Message was edited by:

Anilkumar Vippagunta