Several questions about JAVA Development in ORACLE

Source: Internet
Author: User

I didn't want to write any articles similar to the tutorial, because since it is called a tutorial, it will be able to go through the test of history, for cainiao programmers like me, I just like to share some of my experiences as I like. There is no way to think about it. However, I can't help but explain some problems, because many "tutorials" on the Internet are leading beginners to errors, and some of them are mistakes I personally understand, some authors have never developed but can write an article about software development. They only perform the TRANSLATE, COPY, and CUT operations. The simplest example is that sun's JDK development documentation has so far introduced the methods for storing large objects (files, however, N (N> 100) times of rewriting were not corrected, because later people just copied it and did not actually do it, just replace the original author with your own name.
(Respect statement: All articles signed by AXMAN, a super cainiao, and Shi jianshu will not be posted on any website on the CNJSP website)
Problem 1: to load the JDBC driver:
Normally, there are three ways to load the driver:
1) Class. forName (String) is used to initialize the static content of the driver when loading a class specified by a String in classLoader. In fact, the driver class calls DriverManager. registerDriver (driver); Method
2) Use System attributes: System. getProperty (). load (new FileInputStream ("Property file "));
The advantage of specifying jdbc. driver = drivername in the property file is that multiple JDBC files can be loaded at the same time. If you change the database, you do not need to access the JAVA source code, but only modify the property file.
3) Direct registerDriver (driver) is the most reliable and can be used in any environment.
1) The method is simple, but the JVM of MS cannot be correctly initialized. For example, you cannot use IE in the APPLET. You should use the 3) method. But 3) the method is not as flexible as 2), which can be considered based on the overall environment.
Question 2: Large Object Storage
In general, Large Object Storage stores files in the database. Of course, large strings in the memory can also be used. Of course, files like images are stored in binary format. There are many misunderstandings here. Tutorial 99% on the network is not feasible. Even SUN's own documents are always incorrect, although the errors are very small. Binary files should be stored as BLOB, but JBDC2 cannot directly store BLOB into binary files. If you do this, you will get an IO instead of an SQL exception, it took me nearly two hours to figure it out.
If you want to store a binary file in ORACLE, you need to use the long row type to use standard JDBC:
Create table tb_file (name varchar (20), detail long row );
Then
File file = new File ("aaa.gif ");
Int fileLength = (int) file. length ();
InputStream fin = new FileInputStream (file );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.