Solved

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

Posted on 2001-06-19
8
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

 

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
 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

623 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