How to install run Oracle JDBC: Thin with Java (OAS) DBA on your Linux machine

zhaozj2021-02-11  258

How to install run Oracle on your Linux machine

Starting to install Oracle on RedHat can be quite easy, but if it is completely followed by Oracle's documents, it is not so easy. The fastest shortcut is the homepage of Tom Bisset: http://jordan.fortwayne.com/oracle. If you look at Tom's homepage, you will notice that he misses the JDBC installation. If you are ready to use JDBC (for cross-platform Oracle applications), you can add this option when you ask you to select the component (Components) when you install the screen. Of course, you should first install JDK. I personally use BlackDown JDK 1.1.7. (Translation: Red Hat) Then need to set the ClassPath environment variable of Oracle users, the best way is to add one sentence in the Oracle user directory .Bash_profile or .profile: ClassPath = / usr / lib / jdk / lib / class. Zip; Export ClassPath, if you only need to do the web applet, choose "JDK 1.1 JDBC Thin Driver" when you need to make a complete Java app, choose JDK 1.1 JDBC OCI Driver ". Also note: When the installer allows you to enter each password, if the password does not meet the specification, it will not warn. When I installed the first time, I added ".", This is allowed in Unix, Oracle is another code. The program tells me if the password is issued until the installation is over. At that time, I was a installation from my head. Another problem with the installer is to try to copy files in the directory that has not been established. It is necessary to install MKDIR -P /U01/App/Oracle/server.805/install before installation. This is all over. After the installation is successful, you must log in as root and run root.sh. I made the following changes to root.sh: • Changed from / usr / lbin from / usr / lbin · Increase environment variable log = / tmp / oracle-root.sh.log, such script run results I will record ROOT.SH, I want to run as a server, I must set Two_Task variables first; however, it is actually necessary to set up this variable if ROOT.SH is run from the machine installed in Oracle. Python and Oracle I have configured python (a powerful, fast-oriented scripting language) to test Oracle's programming interfaces and network interfaces. In Python, you want to even Oracle, you need DCORACLE modules for Digital Creation (author of the Zope Application Server). You only need to download the software and do it according to indication. If you are DCORACLE 1.1.0, use the setup-8.0.4 configuration, remove -lsocket, -lnsl, -lgen, -ld, -laio, and -lposix4 from the Oracle_libs variable, which are Solaris is dedicated. Note that the Python settings installed in RedHat 5.2 and 6.0, the config directory and the include directory are omitted, and the modules of the third party cannot be compiled. You must compile python yourself or download a suitable RPM.

Looking for Python's RPM, the best place to go is Oliver Andrich's Python & Linux home page. Just rpm -e --Nodeps Python, then rpm -i python, python-dev, and other RPM. After installing Python, I run the following basic query and access Oracle. [uche @Malesta uche] $ PythonPython 1.5.1 (# 1, SEP 3 1998, 22:51:17) [GCC 2.7.2.3] on Linux-i386copyright 1991-1995 stichting mathematisch centrum, Amsterdam >> IMPORT DCOracle >> > #connect to db. Scott / Tiger Are The Test Database UserName / Password >>> DBC = DCORACLE.CONNECT ("Scott / Tiger @ Sforza") #Sforza Is The Local OraclesRVER >>> C = dbc.cursor ()> >> C.EXECUTE ("Select * from Emp where Emp.deptno = 10") >>> Rows = C.FETCHALL () >>> Print Rows [(7782, 'Clark', 'Manager', 7839, DBIDATE '1981-06-09 00:00:00'), 2450.0, None, 10), (7839, 'KING', 'PRESIDENT', NONE, DBIDATE ('1981-11-17 00:00:00'), 5000.0, None, 10), (7934, 'Miller', 'Clerk', 7782, DBIDATE ('1982-01-23 00:00:00'), 1300.0, NONE, 10)] Development Workstation Configuration I am in the database server Compilation of Python and other programming interfaces on a machine. Initially, it seems that I have to install all Pro * C / C packages of Oracle. But I have to run the Oracle installer to that step, so I don't want to do that. So I found the smallest header file (include), object file (Object) and library file (library): $ oracle_home / lib / * $ oracle_home / rdbms / h * $ Oracle_Home / RDBMS / LIB / * There is oracle_home for / usr / local / oracle. Note that these files have not allowed you to embed the SQL statement directly in the C program, only after the full installation of Pro * C / C is available. If you want to use Java, you have to add $ oracle_home / jdbc / lib / *; pay attention to add this directory to the ClassPath variable. JDBC is connected to test JDBC connections, I made a small program, showing all employee names in the test library in a listbox. The following program 1 is a Java Applet called JDBC, and the program 2 is an HTML hyperbocity that calls the Java program.

If your JDBC is already installed, copy the program 1 to JDBCTEST.JAVA, copy the program 2 to jdbctest.html, then: javac jdbctest.javaappletViewer JDBCTEST.html You can see the results yourself: Program 1: / * Applet what reads in several rows from a remote Oracle Database and presents the in a listbox. * / Import java.sql. *; Import java.awt. *; Import java.applet. *; Import java.lang. *; Public class JDBCTest extends Applet {// Single-select ListBoxprivate List employee_list = new List (5, false) public void init () {setLayout (new BorderLayout ()); try {// Set up the Oracle JDBC driverDriverManager.registerDriver (new oracle. jdbc.driver.OracleDriver ()); // Connect to an Oracle database on machine sforza, using username // "scott" and password "tiger" Connection DB_conn = DriverManager.getConnection ( "jdbc: oracle: thin: @sforza: 1521 : ORCL "," Scott "," Tiger "); // Connection DB_CONN = DriverManager.getConnection (" JDBC: Oracle: Thin: Scott / Tiger @ Sforza: 1521: ORCL "); // Create a jdbc statement ObjectStatement Statement_obj = DB_CONN.CREATESTATEMENT (); // Execute a query to get the employee name from the test DBResultSet results = statement_obj.executeQuery ( "select ENAME fromEMP"); // Populate the list box with all the employee nameswhile (results.next ()) {employee_list.add (results.getString (1));}} catch (SQLException e) {throw new runtimeException ("SQL Exception" E.GetMessage ());} add (employee_list);}}} 程序 2: < HTML> Oracle JDBC Driver Test </ title> </ head> <body> <h1> Oracle JDBC Driver Test </ h1> <applet code = "jdbctest.class" width = "200", Height = "150"</p> <p>> Your Browser Doesn't Support Java. </ Applet> <hr> <address> <a href="mailto:uche.ogbuji@linuxworld.com"> </a> </ address> <! - created: SAT Mar 6 18:53:23 MST 1999 -> <! - hhmts start -> Last Modified: Sat Mar 6 22:19:26 MST 1999 <! - hhmts end -> </ body> </ html > Program 1 is a JDBC call that is unrelated to the specific database, and you can also access PostgreSQL, mainly and Oracle-related parts: Connection DB_CONN = DriverManager.getConnection ("JDBC: Oracle: Thin: @Sforza : 1521: ORCL, "Scott", "Tiger"); Note the format of the URI in Oracle Thin JDBC Driver: JDBC: Oracle: Thin: @ <server_name_or_ip>: <port>: <SID> If you want to include in the URI User name and password: jdbc: Oracle: Thin: username / password @ <server_name_or_ip>: <port>: <SID> The same URI has a longer format: "JDBC: Oracle: Thin: @ (Description = (Address = (Host = <server_name_or_ip>) (port = <port>))) "Note ORCL is the default SID of the system installation (System Identifier, system identifier ). If you use other SIDs during installation, use that SID in the URI. $ Oracle_home / network / admin / tnsnames.ora includes port and SID settings for Oracle Server. This is the configuration file for TNS Listener, Oracle Network Connection Process. If you cannot connect the database over the network, you should first check if the port number and SID are correct, whether the TNS Listner is normal (the translation: lsnrctl status, or tnsping). JDBC is not the only means of developing SQL database applications, and ANSI standard SQLJ allows direct embedding SQL statements directly in the Java program. Oracle for Linux 8.0.5 does not bundle SQLJ, but can be obtained as another independent product. SQLJ is 100% Java, and there is no problem in Linux, in fact, SQLJ is using JDBC in the underlying, so it can be interconnected with any SQL database, not limited to Oracle. I hope that these examples above can help your programming. Unfortunately, the programming document of Oracle for Linux is quite small, or it is hidden very deep :) Maybe before the database is committed, you have to first take one or two books first. PL / SQL Process Language Extensions (PL / SQL) may be the most famous feature of Oracle. This powerful professional database management language allows you to control the declarative SQL.</p> <p>Generally, the stored procedure stored with the command line SQLPlus, the graphical developer / 2000 (currently not currently available on Linux) or other tools, allowing you to have a large number of Oracle (Oracle Application Server, Python) , Perl, JDBC or C) Access. Program 3: create or replace package stored_sample asfunction get_annual_salary (emp_number in number) return number; end stored_sample; / create or replace package body stored_sample asfunction get_annual_salary (emp_number in number) return numberisannual_salary number; monthly_salary number; beginselect sal into monthly_salary from emp where empno = Emp_Number; Annual_Salary: = MONTHLY_SAlary * 24; return (annual_salary); End get_annual_salary; end store_sample; / The program 3 is a small demonstration of the storage process, which accepts an employee number and returns the employee's annual salary. Related functions GET_ANNUAL_SALARY package in PL / SQL package Sample_Package. If you copy the program 3 to the file Sample.SQL, you can run it through SQLPlus, as shown below: [Oracle @ Sforza Demo] $ SQLPLUSSQL * Plus: Release 8.0.5.0.0 - Production on Sun Mar 7 13: 36: 321999 . (c) Copyright 1998 Oracle Corporation All rights reserved.Enter user-name: scottEnter password: Connected to: Oracle8 Release 8.0.5.0.0 - ProductionPL / SQL Release 8.0.5.0.0 - ProductionSQL> @samplePackage created.Package body created . SQL> SET ServerOutput onsql> execdbms_output.put_line (stored_sample.get_annual_salary (7782)) 58800PL / SQL ProCedure SuccessFully Completed.SQL> This PL / SQL package can also be used by other programming interfaces. In Python / Dcoracle, see the procedures member JDBC of the Connection object, see Java.sql.callableStatement. Oracle has a wide range of built-in functions. In fact, most of the functions that have been completed with external code can be completed efficiently by PL / SQL. If you need any more usual features, please refer to the PL / SQL manual to see if the function you need is already implemented. If you are ready to do a lot of Oracle programming, you often flip through the PL / SQL manual to familiarize all kinds of functions. Manage Oracle for Linux If you are used to run a relatively uncompletely complex database, you have completed some daily operations in Oracle, such as establishing a new database or performance tuning. It is quite complicated.</p> <p>There are some key configuration files to be maintained, such as init.ora, config.ora, and tnsnames.ora. There are general ways to specify some key parameters, such as the current SID. It can be declared in the above files, or in an environment variable, or through the Oracle tool running parameters. This kind of flexibility is worthy of appreciation, but unfortunately, it is time to get the setting is also very hurtful. Like Linux, if the security mechanism provided by Oracle is not properly managed. Time is familiar with various access rules and settings, as well as the roles of a variety of special Oracle user accounts, or worth it. Oracle's performance tun is a very large, very specialized topic. Tuning is properly improved. Oracle runs and CPUs, memory, and exemptions are quite complex, these factors must be considered. In addition, the PL / SQL package, the stored procedure, the temporary table space, the table structure itself, all of which are increasingly complex with use, ensuring the structure of the database, no garbage, absolutely more complicated from cron running Vacuum periodically. Oracle DBA (Database Adminstrator, Database Administrator) is a famous subcommittee in computer professionals. This is not surprising. Oracle's powerful features and flexibility, while also mean all kinds of small secrets, tips, small traps, this feature is less than anyone - including Linux. You may have discovered that O'Reilly Zoo (Translation: All O'Reilly and Associate published books) is a good place for animals. If you need to complete a lot of work on Oracle, find the O'Reilly Oracle album of the yellow cover. There, you will find more information sources than Oracle Byzing Tria. Oracle for Linux VS. Oracle on Oracle for NTNT (Moracle: Oracle Sales exceeds SQL Server, is NT Larger Database) Provides a graphical interface for many management functions, similar features on UNIX / Linux only Can be accessed through SQLPLUS. Such a graphical interface is designed to be similar to the other parts of the NT control panel. Linux DBA must be familiar with SQLPLUS. NT problem is that many administrative tasks require users to complete in the main control station (before the machine screen), if you want to remotely require expensive third-party software (or Oracle Enterprise Manager?). Oracle management on UNIX can be performed from any authorized far, the effect is the same as the machine main control. Oracle on NT uses multiple processes in a process, while Oracle on UNIX / Linux uses multiple separate, independent memory spaces (translation: Multithreaded Server, MTS, equivalent to The listed multi-threaded version mentioned in the previous article.) The implementation of the NT avoids inter-process communication, small performance advantages, but the implementation of UNIX provides much more reliability and data integrity, because one The Oracle process is not possible to pollute the address space of another Oracle process. (Translation: On NT and VMS, creating a new process is much more expensive than creating a new thread, and there is a slow switch between NT processes, and Microsoft recommends that programmers will use multithreaded. On UNIX, Establishing a new process is relatively efficient.</p> <p>On Linux, establish new processes and new kernel threads, Kernel Thread uses the same basic system call, which is quite high. ) On a 32-bit hardware system, Linux's EXT2 file system limits the maximum file is 2G, NT is 4G. This does not affect Oracle users because table space TableSpace can extend to multiple files, but there is still a small efficiency issue. Of course, 64-bit Linux (Alpha, Ultra-SPARC, PA-RISC) will eliminate these limits, the same 64-bit Solaris (Solaris 7). (Translation: There are actually some problems here, and I will find out to explain to all the officials. Some Good tools / Conclusion Oracle also released the LINUX version of Oracle Application Server (OAS). In-depth discussion of OAs is outside this article, but it is indeed a powerful tool that connects the backend Oracle database to create an Internet or intranet application. OAS provides Java development capabilities, you can string from HTTP and IIOP to OCI network interface, with friendly interfaces to design web forms and reports, and other convenient tools. Oracle is so popular, naturally has a corresponding batch of open source software (Open Source) tools. The OWS Killer is a web interface tool that can replace the OAS, integrate with the Apache Web server, Apache's JSERV Java ServeT module, providing access to Oracle databases. (Translation: OWS, Oracle Web Server is the name of the Oracle Application Server earlier). You can find more tools in Matt's House to manage Oracle stored procedures, provide fast reporting capabilities. Mastering Oracle is not a thing of the hand, but it is not necessary to hope. Indeed, there are many more easily managed databases, but you will find if you need advanced SQL, or PL / SQL functionality, or TRIGGER, or various extensions, or advanced transaction management, or must coexist with the Oracle system. Linux is an excellent Oracle platform. You have explored this far in Linux's world and must also deal with Oracle challenges. (Author: breakage Source: Osorio)</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-3680.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="3680" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.032</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'Cq5hf6ChjooD_2BJUK5ITAlJ_2B6snPMOBlEg56Gvthm54o58AdSRpcnc1QZyZpOVzuYgXuV5lzeD8NpJ0A6OMpWRg_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>