Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in connecting Oracle9i thru wsad5.0

 
srinivasa reddy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I am just trying one of the example in this site,i am using Oracle 9.0.01 and WSAD5.0, i could not connect to database,
java.sql.SQLException: [Microsoft][ODBC driver for Oracle][Oracle]no result
I have included classes12.zip in the path,created the odbc driver.As i am new to java and wasd , sending detailed procedure to get connection with oracle 9i will be more helpful.
Here i am sending the code.
import java.io.*;
import java.util.*;
import javax.servlet.*;
import java.sql.*;
import javax.servlet.http.*;
public class OriellyExamples extends HttpServlet{
Connection dbConnection;

/* public void init()
{
// ServletConfig config=getServletConfig();

// System.out.println(getServletName()+":Initializing...");

// String driverClassName=config.getInitParameter("driverclassname");

// String dbURL=config.getInitParameter("dburl");

// String username=config.getInitParameter("username");

// String password=config.getInitParameter("password");

/* try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

}catch(ClassNotFoundException e){System.out.print("beep");}

/* try
{
dbConnection=DriverManager.getConnection("jdbc
dbc b1","hello","welcome");
}catch(SQLException e){}

System.out.println("Initialized");*/
// }

public void service(HttpServletRequest req,HttpServletResponse
res) throws ServletException,IOException {
PrintWriter pw=res.getWriter();
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Class.forName("oracle.jdbc.driver.OracleDriver");

dbConnection = DriverManager.getConnection("jdbc dbc:esr","scott","tiger");
//dbConnection = DriverManager.getConnection("jdbc racle:thin:@localhost:1521:esr","scott","tiger");
Statement smt=dbConnection.createStatement();

ResultSet r = smt.executeQuery("SELECT * FROM emp");

pw.println("<html>");
pw.println("<body>");

pw.println("<h1>hello</h1>");

while(r.next())
{
int j=r.getInt("ID");
String s = r.getString("name");
pw.println("ROW = " + " " +s+ " " + j);
}
pw.println("</body>");

pw.println("</html>");
smt.close();

dbConnection.close();
}
catch(Exception e)
{
pw.println("<html>");

pw.println("<h1>"+e+"no result</h1>");

pw.println("</html>");
}
}
Exception is:java.sql.SQLException: [Microsoft][ODBC driver for Oracle][Oracle]no result
help appreciated
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic