Solved

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

Posted on 2001-06-19
8
255 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Python Assistance 7 71
groovy example issue 10 88
create a gui in perl 3 69
servlet example issue 6 29
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…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

930 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

9 Experts available now in Live!

Get 1:1 Help Now