Oracle learning notes

xiaoxiao2021-03-06  64

Although I have used Oracle to develop work, it is the environment that others have a good job, and other databases are not different. This time, starting from scratch, step by step. 1 Let's find some website to download some developed documents, address http://www.itpub.net/266137 ,1.html 2 and then start installing, with a wizard, it seems that there is no big problem 3 Start building a new database: use Run CMD, C: / DBCA Installation Configure Database. C: / LSNRCTL Start Listing 4 In addition to the specified database service and listening service, other services can stop saving the memory 5 Oracle comes with the JDBC source code analysis: MXCLXP (original)  Dafan used JDBC even Oracle Will know such a fact: we need the library files 12.zip exists in the $ Oracle_Home / JDBC / LIB directory (but still some rookie every time you ask this library file in the forum, but very little people know Oracle For example, an example of using JDBC is presented, it exists in $ Oracle_Home / JDBC / DEMO / DEMO.ZIP. For a while, I learned Oracle's OOP technology and was very touched. At that time I thought: There must be some OO technology in JDBC to support it. I haven't found a suitable example for a long time, and finally find it in the Oracle installation directory. It is true that it is: walking through the iron shoes, you have to come to the family.  Agreement: 1, if java.lang.unsatisfiedlinker: do_open, you need to modify the URL of the DriverManager.getConnection () method to JDBC: Oracle: Thin: @ 127.0.0.1: 1521: ORADB , Specific reasons unknown; .zip with a directory);  I will make a detailed function description of the files under Folder / Samples / Oci8 / Object-Samples: 1, PersonObject.java This example is demonstrated There is ADT field EMPID in Table People, and its type is Person, and the type Person exists in the ADT field Home, which is Address, and the type Address is an ADT.  If you use a regular SQL statement, its insertion statement is not different in SQL / PLUS, namely: use constructor nested constructs.  There is another method that constructs a struct object using the structural constructor structure of the Struct (StructDescriptor, Connection, Object []), which is an ADT object. At the same time, if there is nested, it is necessary to nearest the constructive ADT object. Finally, the ADT object can be specified by the setObject method of PreparedStatement.  When reading data, it is used to reverse the above method: if it is a simple type, read directly; if it is ADT, use the resultset's getObject (), then force to convert to Struct, then call Struct The GetAttributes () method obtains object [] type data, such as recursive. 2, SqlDataExample.java and Employeeobj.java  This example is similar to 1, but also the processing of ADT, the same is that the type is not nested.

 Comparison, 2 to 1 code is simple, but also paying the price: for type Employee abstract a class EMPLOYEOBJ, which implements the SQLDATA interface and rewrites three methods (must).  The second method in the front desk is simpler, only a lot of time, just specify the ADT object directly using the setObject method of PreparedStatement (but you need to specify its type Oracletypes.struct). You can also use the oracleresultset's getObject () and force to convert to an EmployeEOBJ object.    是 是 是 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地 地. 地 地 地................................ Import oracle.jdbc. *; Reasons unknown; Dictionary map = conn.gettyPemap () in sqldataexample.java; change to java.util.map map = conn.gettypeMap (); reason: Note:  This class (refer to Dictionary) is obsolete New implementations should implement the Map interface, rather than extendidng this class.. (source: javadoc); in 2.3 SQLDataExample.java pstmt.executeQuery (); changed pstmt .executeUpdate (); more reasonably, because this is an update rather than a query (no change will not affect the function, just suggestions); 3, customDatumexample.java and Employee.java Otamed. Different from another abstract technology and implements interface CustomDatum and CustomDatumFactory, and override two methods Todatum () and Create (). There is also a little different when accessing data at the front desk: The getCustomDatum () method of ORACleResultSet is used and converted to EMPLOYEE. From the appearance, 2 in the SQLDATA interface exists in the java.sql. * Pack; and the interface CustomDatum and CustomDatumFactory are in Oracle.SQL. * Pack, which can be considered to be dedicated to their own products. Maybe there is a higher performance, smaller overhead? However, 3 is not as direct, individuals think. 4, arrayexample.java From the file name, this example demonstrates the Varray type.   1, there are two ways to insert. A SQL can be used directly; in addition, it can use the setArray method for OraclePrepareDStatement, and the process of constructing Array is not different from the construction Struct. The reading process of the data is reversed: First use the oracleresultset's getArray () method to get the Array object, then call the GetArray () method of this object and force to convert to an object array and then operate to this array.  5, Personref.java and Studentref.java  I don't know if Oracle is joking with us. In addition to the class name, the other is the same.  This example gives us the concept of object table.

转载请注明原文地址:https://www.9cbs.com/read-85975.html

New Post(0)