The most basic Oracle database connection code (for oracle11g only):1, right-click Project, build path, configuration build path, select the third item "Library", then click "Add External Jar" and select "D:\Oracle\app\oracle\product\11.2.0\server \jdbc\lib\ Ojdbc6_g.jar "(Note: D:\Oracle is the installation path for the database).2. The following code is a very standard example of Oracle database connectio
Small Example of tcp in java
Server:
ServerSocket service = new ServerSocket (7777); Socket socket = service. accept (); InputStream input = socket. getInputStream (); OutputStream out = socket. getOutputStream (); BufferedInputStream bufinput = new BufferedInputStream (input); BufferedOutputStream bufout = new BufferedOutputStream (out); bytes [] buf = new byte
constraints, the full use of CPU and memory potential, is the core content of performance optimization.And how is CPU and memory dragged down by IO? This starts with several typical IO operating modes in Java.Ii. Typical IO operation mode in Java 2.1 synchronous blocking modeThe bio-style API in Java is the pattern, for example:Socket socket =// cannot read data vow not to returnIn this mode, the most intu
the operating system can still only dispatch a limited number of threads. For example, the Linux system can refer to the discussion here: Maximum number of threads per process in Linux?.In addition, when a large number of threads switch, it will also incur the overhead of context loading and unloading, which will also degrade the performance of the system.Scalable IODoug Lea The Great God has a very classic pptscalable IO in
Demofindandsort (Dbcollection articlecollection, Basicdbobject searcharticlebyauthor
{//Find and print the author as "fansunion" articles, sorted by ID descending println ("Find and print the author Fansunion article, descending order, the ID of the query is 3,2,1");
Basicdbobject Orderbyiddesc = new Basicdbobject ();
Orderbyiddesc.append (ID,-1);
Dbcursor Cursoriddesc = Articlecollection.find (searcharticlebyauthor). Sort (ORDERBYIDDESC);
while (Cursoriddesc.hasnext ()) {print (Curso
This way, if you do not log in and access commonuser.jsp directly, you will jump to the login interface.
3, the use of special documents to verify
Because many pages have to write validated code, you can put this code in a file to share, need to use the call to share files. The following still takes commonuser.jsp as an example of how to implement the sharing of validation code.
Use specialized files to store shared code:
Check.jsp Code:
First, build a Doc folder under the WebApps download project under the Tomcat server and build a test.doc. Prevent pointer exceptionsDownload.java Code1 PackageCom.down;2 3 Importjava.io.IOException;4 ImportJava.io.InputStream;5 6 Importjavax.servlet.ServletException;7 ImportJavax.servlet.ServletOutputStream;8 ImportJavax.servlet.annotation.WebServlet;9 ImportJavax.servlet.http.HttpServlet;Ten Importjavax.servlet.http.HttpServletRequest; One ImportJa
/** * Run shell script * @param shell script required to run */public static void Execshell (String shell) {try {runtime RT = Runtime.getrunt IME (); rt.exec (shell);} catch (Exception e) {e.printstacktrace ();}} /** * Run Shell * * @param shstr * required to execute shell * @return * @throws ioexception */public static List Runshell (String s HSTR) throws Exception {listRemotely log in to Linux and invoke the shellFirst write a test script test.sh on the remote
parallel. Practice has proved that the multi-thread design can improve the system response and ensure the independence of user instruction execution. Java itself is "thread-safe", so there is a programming principle that a new thread should be opened up for operations that can be completed independently in a thread.---- There are two ways to implement threads in Java. One is to generate a subclass of the T
In the previous "OpenSSL and keystore instruction small set," said the recent study of SSL encryption, will give a small example of Java. Copying a piece of code that can run to production is very irresponsible, but a small example can lead us to a quick glimpse of the nature of things. Rome was not built in a day.This article will give a small
the original data type of the returned byte array (webpage, image, and others). For example, the returned header information is as follows:
Content-Type
text/html
The returned byte array is originally an html page. The browser parses the html page and displays the data. If the server returns the following header information:
Content-Type
image/jpeg
The returned byte array
the following occurs:
Time
Thread A
thread B
T1
A1: Allocating memory space for an object
T2
A3: Set instance point to memory space
T3
B://1 to determine if instance is empty
T4
B: Because instance is not NULL, thread B will return the object referenced by instance
T5
B:instance not initialized, there may be an unknown problem
establishes a connection to the Web server, and opens a virtual file called a socket (socket), which marks the successful connection establishment;
Request, the Web browser submits the request to the Web server via the socket. HTTP requests are typically a GET or post command (post is used for a form parameter pass);
Answer, the Web browser submits the request and passes it through the HTTP protocol to t
The sun.net package contains many protocols, such as FTP, SMTP, and www.
The ftpclient class in the FTP package can implement an FTP client, which provides some common FTP commands, such as connecting to the server, logging on to the server, and uploading and downloading files.
The related methods are encapsulated with FTP commands, which can be conveniently call
Java-based implementation of a simple HTTP server (RPM) This article will detail how to implement a simple HTTP server based on the Java language, the article will mainly introduce three aspects of the content: 1) The basic knowledge of the HTTP protocol, 2) Java.net.Socket class, 3) Java.net.ServerSocket class, after
business logic. .Further, the information that travels back and forth between the application server and its clients (traveling) is not limited to simple display markup , such as Static HTML, the information passed back and forth includes (takes) data and method calls (calls) .and the application server is a lot of protocols to provide (serves) business for applications or clients ( business ) logic (busin
focuses on how to create restful Web Services using the Jersey framework. The jersey framework implements the Jax-rs interface. The sample code in this article was written using Eclipse and Java SE 8. A. New project: RESTFULWS, then create a RESTful Web service server
Create a Dynamic Web project in Eclipse, with the project name set to "RESTFULWS".
Download jersey (https://jersey.g
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.