on 08-31-2007 2:58 AM
HI All
i am very new to Developer Studio,
i want to connect to an oracle database through wedynpro java.
i have seen some tutorials on SDN. i know something about adding external JARs and OJDBC .
Can anyone send me the sample code to connect to a database
<b>very urgent</b>
Thanks in advance
Sushma
Hi Sushma
Ask your system Admin for servername,portnumber of database server
Connection conn=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn =DriverManager.getConnection ("jdbc:oracle:thin:@<servername>:<portnumber>:DB","uname", "pwd");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from <tablename>"); // select statment
while(rs.next())
{
IXXElement nodeConnection=wdContext.createXXElement(); //creating a node to store the data from oracle
nodeConnection.setYY(rs.getInt("YY")); // setting the values into input fields
nodeConnection.setAA(rs.getInt("AA"));
nodeConnection.setBB(rs.getInt("BB"));
...
...
..
wdContext.nodeXX().addElement(nodeConnection); // adding the node
}
}
catch(Exception ex)
{
}
finally
{
try
{
conn.close(); // closing the connection
}
catch(Exception e)
{
}
}
welcome to SDN and All the best from SDN Webdynpro JAVA
Regards
Chaitanya.A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.