Solved

applet<---->servlet(oracle oci driver)<----->oracle database?

Posted on 2001-06-19
8
253 Views
Last Modified: 2013-11-24
Hi everybody,
   I try to access oracle database by oci driver using servlet.anybody can tell me how to do it?
  thanks.
0
Comment
Question by:li6183
  • 3
  • 3
  • 2
8 Comments
 
LVL 3

Expert Comment

by:superschlonz
ID: 6208346
Driver driver = Class.forName( "oracle.jdbc.driver.OracleDriver" ).newInstance();
DriverManager.registerDriver( driver );
Connection conn = DriverManager.getConnection( "jdbc:oracle:oci8:@<tnsname>", "user", "pass" );

Have also a look at: http://technet.oracle.com/tech/java/jroadmap/jdbc/listing.htm#998514
0
 
LVL 3

Expert Comment

by:superschlonz
ID: 6208354
An more informations about JDBC you find at:
http://java.sun.com/products/jdbc/
0
 
LVL 4

Expert Comment

by:rdov
ID: 6209360

   try {
       Class.forName("oracle.jdbc.driver.OracleDriver");
       Connection con = DriverManager.getConnection("jdbc:oracle:thin:@orads:1521:ecart","ecart","ecart");

("jdbc:odbc:test","ecart","ecart");
       con.setAutoCommit( false );

       Statement stmt;
          stmt = con.createStatement();
       String queryString = "select * from Categories";
       ResultSet rs = stmt.executeQuery(queryString);
       boolean moreNames = true;
       if (!(rs.next())) {
          moreNames = false;
       }

        while (moreNames) {
           while (rs.next()) {
               String s = rs.getString("cat_name");

               out.println("Category ID: " + s + "
");
         if (!(rs.next())) moreNames = false;
       }
    }
       // print out decent error messages

    catch(SQLException SQLe) {
      out.println("Message:   " + SQLe.getMessage ());
         out.println("SQLState:  " + SQLe.getSQLState ());
         out.println("ErrorCode: " + SQLe.getErrorCode ());
 }
 catch (ClassNotFoundException e) {
   out.println("Message:   " + e.getMessage ());

 }

http://developer.java.sun.com/developer/onlineTraining/Database/JDBCShortCourse/index.html

http://wpi.wpi.edu/java.815/a64685/basic1.htm#1004398

http://otn.oracle.com/tech/java/jroadmap/jdbc/listing.htm

download classes12.zip JDBC driver from:
http://otn.oracle.com/software/tech/java/sqlj_jdbc/software_index.htm

0
 

Author Comment

by:li6183
ID: 6210539
thanks, everybody,what rdov wrote is for oracle thin driver,and it is not exactly what I want.I try to implement applet communicate with servlet, and servlet runs at apache web server, and it will access oracle database. I can implement it using oracle thin driver. but as you know, if you using thin driver, you  must specify the oracle server name(hostname) and port number. if you want to access different database server, you must change the hostname in your source code. it is not good. so I want to use oracle oci driver, and I can access just by <tnsname>.anybody knows what I should deploy apache web server in order to use oracle oci driver?
 
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 4

Accepted Solution

by:
rdov earned 50 total points
ID: 6210867
0
 

Author Comment

by:li6183
ID: 6211689
thanks rdov,I have read the white page what you offered(http://technet.oracle.com/tech/java/sqlj_jdbc/htdocs/jdbcwhpap.htm).inside this article,there are two methods about
JDBC/OCI Driver 3-Tier Configuration(A and B). I am confused about them, what I did is very similar with configuration B,the different is that the configuration B said the protocol between applet and servlet is either RMI or COBRA(IIOP), but I used http protocol. I don't know whether or not it is viable?


 
0
 
LVL 4

Expert Comment

by:rdov
ID: 6213551
if the servlet communicates with the ORACLE DB it should be fine to send the retrieve data to the applet through http protocol. but if the applet needs to communicate the DB directly it should be a problem to do this through http protocol without thin driver.
0
 

Author Comment

by:li6183
ID: 6214342
yes rdov,I have same idea with you,so I don't know why the whitepage say so.by the way, if you want to use applet communicate with DB directly, maybe the ids driver is better than thin driver.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now