Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2001-06-19
8
Medium Priority
?
266 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

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…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

916 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