First, the concept of the four drivers
A, JDBC-ODBC Bridge
Bridge-type drivers, drivers of such characteristics is the need to end users on the computer pre-installed good ODBC driver, and then through JDBC-ODBC call, then to access the database through ODBC.
After JDK1.1 as part of the package is part of Application sun.jdbc.odbc —> JDBC-ODBC Bridge -> JDBC-ODBC Library —> ODBC Driver -> Database applicable to the rapid prototype system did not provide a database such as JDBC Driver Access
B, JDBC-Native API Bridge
Driver is one of the bridges, such procedures must first drive in the computer users to install specific drivers (similar ODBC), and then through JDBC-Native API bridge the conversion to Java API calls into specific driver call, then access the database.
Use of the local library developers to provide direct communications with the database. Application —> JDBC Driver -> Native Database library -> Database than Class A slightly better performance.
This type of drive is the biggest benefit program omitted in the computer users to install any driver trouble, just installed in the server middleware, and middleware will be responsible for all the necessary access to the database conversion. Application —> Jdbc Driver —–> java middleware —> JDBC Driver -> Database with the greatest flexibility, usually by non-database vendors, is the smallest of the four types.
D, Pure JDBC driver
This type of driver is the most mature JDBC drivers, computer users will not need to install any additional drivers, do not need to install any intermediary server-side procedures (middleware), all access to the database operation, directly by the driver to complete.
Application —> Jdbc driver —–> database engine —> database highest performance, through their own local agreements directly with the database engine communications, and have the ability to assemble the Internet. JAVA paradise
Second, with the commonly used method of JDBC
1, DriverManager categories:
Responsible for the management of JDBC driver. Before using JDBC driver must be loaded first driver to DriverManager registered before they can use at the same time providing a way to establish the database connection.
A, Class.forName (String driver); / / load the registration drive procedures
B, Static Connection getConnection (String url, String user, String password) throws SQLException;
/ / Database connections made
C, Static Driver getDriver (String url) throws SQLExcetion;
/ / To DriverManager already registered in the search for a driver to open the url specified by the database driver
2, Class Connection
Responsible for the maintenance of JSP / JAVA between the database and database online. Can be very useful to establish three categories of objects.
A, Statement createStatement () throws SQLException; / / object of the establishment of Statement
Statement createStatement (int resultSetType, int resultSetConcurrency) throws SQLException;
/ / Object of the establishment of Statement
TYPE_FORWARD_ONLY result set can not be rolling
TYPE_SCROLL_INSENSITIVE results can be set rolling, do not reflect the changes in database
TYPE_SCROLL_SENSITIVE results can be set rolling, reflecting changes in the database
CONCUR_READ_ONLY result set can not be used to update data
CONCUR_UPDATABLE results can update data
JDBC2.0 support only in the result set rolling, and the data can be updated JAVA paradise
B, DatabaseData getData () throws SQLException; / / object of the establishment of DatabaseData
C, PreparedStatement prepareStatement (String sql) throws SQLException;
/ / Object of the establishment of PreparedStatement
D, boolean getAutoCommit () throws SQLException / / Connection object of the AutoCommit
E, void setAutoCommit (boolean autoCommit) throws SQLException
/ / Set Connection AutoCommit state of the object
F, void commit () throws SQLException / / determine the implementation of the database add, delete or modify the operation of record
G, void rollback () throws SQLException / / Cancel the implementation of the database add, delete or modify the operation of record
H, void close () throws SQLException / / Connection object on the end of the on-line database
I, boolean isClosed () throws SQLException / / test whether the object type has been closed Connection database online
3, Statement of
Statement provided by the adoption of the method, we can use standard SQL commands, the database directly add, delete or modify operation
A, ResultSet executeQuery (String sql) throws SQLException / / use the SELECT command of the database query
B, int executeUpdate (String sql) throws SQLException
/ / INSERTDELETEUPDATE use of the database add, delete and modify operations.
C, void close () throws SQLException / / end of the Statement of object database online
4, PreparedStatement category
PreparedStatement and Statement of the different type of object is PreparedStatement category will be imported prior completion of SQL commands for use when a single SQL commands than many implementation, will be used PreparedStatement type of efficient than Statement
A, ResultSet executeQuery () throws SQLException / / use the SELECT command of the database query
B, int executeUpdate () throws SQLException
/ / INSERTDELETEUPDATE use of the database add, delete and modify operations.
C, ResultSetData getData () throws SQLException
/ / A ResultSet object of the relevant information related fields
D, void setInt (int parameterIndex, int x) throws SQLException
/ / Set numerical integer type of object to the PreparedStatement IN parameters
E, void setFloat (int parameterIndex, float x) throws SQLException
/ / Set numerical float type of object to the PreparedStatement IN parameters
F, void setNull (int parameterIndex, int sqlType) throws SQLException
/ / Set NULL values to the type of object IN PreparedStatement parameters
G, void setString (int parameterIndex, String x) throws SQLException
/ / Set numerical string to the type of object IN PreparedStatement parameters
H, void setDate (int parameterIndex, Date x) throws SQLException
/ / Set the date type of numerical targets to the PreparedStatement IN parameters
I, void setTime (int parameterIndex, Time x) throws SQLException
/ / Set the time to the type of numerical targets of the PreparedStatement IN parameters
5, DatabaseData category
DatabaseData preservation of all the features of the database, as well as provides numerous ways to obtain such information.
A, String getDatabaseProductName () throws SQLException / / name of the database
B, String getDatabaseProductVersion () throws SQLException / / version of the database, code-named
C, String getDriverName () throws SQLException / / obtain the names of JDBC Driver
D, String getDriverVersion () throws SQLException / / obtain JDBC Driver version of the code
E, String getURL () throws SQLException / / make connecting to the database JDBC URL
F, String getUserName () throws SQLException / / obtain the login user account database
6, ResultSet category
Query the database for storage of the results. And offer a range of methods of database add, delete and modify operations. Also responsible for maintaining a record pointer (Cursor), the record pointer at the data in a table records, the adoption of appropriate mobile record pointer, database access can go to strengthen the effectiveness of the procedure.
A, boolean absolute (int row) throws SQLException / / mobile record pointer to the specified records JAVA paradise
B, void beforeFirst () throws SQLException / / mobile record pointer to the first record before
C, void afterLast () throws SQLException / / mobile record pointer to the final after a record
D, boolean first () throws SQLException / / mobile record pointer to the first record
E, boolean last () throws SQLException / / mobile record pointer to a final record
F, boolean next () throws SQLException / / Mobile recorded a pointer to the next record
G, boolean previous () throws SQLException / / mobile on the record pointer to a record
H, void deleteRow () throws SQLException / / delete the record pointer at the record
I, void moveToInsertRow () throws SQLException / / mobile record pointer to a new record
J, void moveToCurrentRow () throws SQLException / / mobile record pointer to the memory record
K, void insertRow () throws SQLException / / a new record in the database
L, void updateRow () throws SQLException / / modify a record in the database JAVA paradise
M, void update types (int columnIndex, type x) throws SQLException / / modify the value of the specified field
N, int get types (int columnIndex) throws SQLException / / obtain the value of the specified field
O, ResultSetData getData () throws SQLException / / object of the ResultSetData
7, ResultSetData category
ResultSetData preservation of objects of all ResultSet object on the field of information and provide many ways to obtain such information.
A, int getColumnCount () throws SQLException / / Gets ResultSet object of the number of fields
B, int getColumnDisplaySize () throws SQLException / / Gets ResultSet object of the length of the field
C, String getColumnName (int column) throws SQLException / / Gets ResultSet object of the field name
D, String getColumnTypeName (int column) throws SQLException / / Gets ResultSet object of the field type name
E, String getTableName (int column) throws SQLException / / Gets ResultSet object of their field data sheets name
F, boolean isCaseSensitive (int column) throws SQLException / / test ResultSet object of the field is case-sensitive
G, boolean isReadOnly (int column) throws SQLException / / type test ResultSet object if a field is read-only
(Editor: Xun Gong)
Do not advocate the use of the method is to support backward compatibility while retaining those methods, which in future editions may arise or may not arise. Java multi-threading support in version 1.1 and version 1.2 had done in a major revision, stop (), suspend () and resume () function is not to promote the use of. These functions may be introduced in the JVM subtle mistakes. Although the function names may sound very tempting, but please resist the temptation not to use them.
Threaded debugging procedures
In the thread of the process, the potential of some common and annoying is Deadlock, live lock, memory damage and depletion of resources.
Deadlock is a multi-threaded program may be the most common problem. When a thread needs a resource and another thread holding the lock resources occurs when the deadlock. This usually difficult to detect. However, the solution is quite good: In all the threads in the order by the same access to all the resources lock. For example, if there are four resource - A, B, C and D - and a four-thread access to resources may be a resource in any lock, please ensure that the access to the lock on the B of A before the first access to the lock, and so on. If the "one thread" We hope that access to the B and C of the lock, "Thread 2" access to the A, C and D locks, this technology could lead to obstruction, but it will never be locked in this four Deadlock caused.
When a thread busy to accept new tasks so that it never have a chance to complete any task, it will lock of life. This thread will eventually exceed the buffer zone and lead to the collapse of procedure. Imagine a secretary need a letter from the input, but she has been busy with the phone, so this letter will never be recorded.
If the wise use of synchronized keyword is entirely avoidable memory errors such Qisi them.
Some system resources are limited, such as the file descriptor. Multithreading procedures may depletion of resources, since each thread may want to have such a resource. If a considerable number of threads, or threads of a few candidates resources far exceeds the number of resources available, the best use of resources pool. The best example is a database connection pool. As long as the threads need to use a database connection, it removed from a pond, then use it later returned to the pool. Chi, also known as resource pool.
Debugging a large number of threads
Sometimes a procedure because a large number of threads running and extremely difficult to debug. In such circumstances, following this category may come in handy:
Equals of the importance of not to say, if you want to compare two objects to the same object, you should realize
Equals method, do you think clients in the same conditions for comparison.
Below is the content of the standard API, nothing too deep significance, but I was the first to put it out here, because the fact that these norms are not really be achieved can be guaranteed.
1. Used for any type of o.equals (o) == true establishment.
2. If o.equals (o1) == true, then the o1.equals (o) == true also must set up.
3. If o.equals (o1) == and the establishment of true o.equals (o2) == true, then
O1.equals (o2) == true also set up.
4. If, in the first call o.equals (o1) == true and o1 o set up to the circumstances have not changed any time after the call is set up.
5.o.equals (null) == true not set up any time.
More than a few rules is not the most complete description, see detailed API documentation.
The Object class, it provides a tight issue of the utmost the realization that only the same object, the method will return to the equals
True, which is the often-mentioned comparison is not invoke comparison. Closely in the realization of this has been of little practical significance,
Therefore, in specific sub-categories (as opposed to, Object), if we are to compare the value of a target, we must realize their own
Let us first look at the following this procedure:
Public boolean equals (Object obj)
If (obj == null) return false;
If (! (Obj instanceof FieldPosition))
FieldPosition other = (FieldPosition) obj;
If (attribute == null) (
If (other.attribute! = Null) (
Else if (! Attribute.equals (other.attribute)) (
Return (beginIndex == other.beginIndex
== & EndIndex other.endIndex
== Other.field & field);
This is the standard JDK in java.text.FieldPosition realize, there is nothing to say.
I believe the vast majority of the majority or programmers that this is the correct legal equals to achieve. JDK After all, it is the API to achieve ah.
Let the facts speak for it:
Import java.text .*;
Public class Test (
Public static void main (String  args) (
FieldPosition fp = new FieldPosition (10);
FieldPosition fp1 = new MyTest (10);
System.out.println (fp.equals (fp1));
System.out.println (fp1.equals (fp));
(Class MyTest extends FieldPosition
Int x = 10;
Public MyTest (int x) (
This.x = x;
Public boolean equals (Object o) (
If (o == null) return false;
If (! (O instanceof MyTest)) return false;
Return ((MyTest) o). X == this.x;
Try running what will be printed out:
System.out.println (fp.equals (fp1)); Print true
System.out.println (fp1.equals (fp)); Print flase
Two objects, there has been equals asymmetric algorithms. Problem where (Naojinjizhuaiwan: JDK achieve in the course of the BUG)?
I believe that there are too many programmers (with the exception of those who simply do not know the methods to achieve equals outside programmers) in the realization equals instanceof methods are used to carry out operations at short circuit optimization, seek truth from facts to say that for a very long time so I used .
Too many tutorials, documentation gave us such misleading. Some programmers have some understanding of the optimization may be aware that this may be some wrong but not find the key. Another extreme is that the ashes of the technical defects on the proposed expert-level applications such not.
We know that, "normally" to compare the two targets, they "should" is the same type. Therefore, the first to use instanceof
Operating at a short-circuit optimization, if the object of comparison and the current target is not the same type of comparison is not to return false, but the fact is, "the father of sub-class is an example of" Therefore, if the sub-class of o instanceof father, and always return true, then certainly not short circuit optimization, the following are more likely to arise many cases, a modeling is not thrown out into sub-type anomalies, and the other is the father of the private members did not inherit quilt category and not to compare the other is the formation of this asymmetry above comparison. May be too many cases.
Well, is it can not be used at instanceof to optimize the operation? The answer is no, there are still many JDK in the realization of the right, if a class is the final, knowing that it can not be sub-class, why not instanceof to optimize?
SUN In order to safeguard the reputation of the development team, I do not indicate which category, but there are members of a group to use this method of optimization, in the post-jerk on the attributes of such Notes:
If (this == obj) / / quick check
If (! (Obj instanceof XXXXClass)) / / (1) same object?
May be some doubt, but I do not know how to do (do not know why I did not call the ……)
So for non-final category, how type of quick check?
If (obj.getClass ()! = XXXClass.class) return false;
Compared with the target object class and the current object class comparison, seems to be no problem, but if this kind of no-return to class equals, then in the category of comparison, obj.getClass () certainly does not mean XXXCalss.class,
Is the type of equals will be null and void, so if (obj.getClass ()! = This.getClass ()) return false; is the correct comparison.
Coding method combined in many aspects of software development. Although they are usually on the application does not affect the function, but they are to improve the understanding of the source code to be helpful. Here consider all forms of source code, including programming, script writing, marking and query language.
Here is not recommended definition of a method of coding a fixed set of coding standards. On the contrary, they are designed to develop specific software projects as the coding standard guide.
Coding method is divided into three parts:
Application procedures for understanding the logic flow, the programme is named the most influential of a help. Name should describe "what" rather than the "how." By avoiding the use of public realization basis (they will change) the name, can be retained to simplify the complexity of the abstraction layer. For example, you can use GetNextStudent (), rather than GetNextArrayElement ().
Naming principles are: to choose the correct title of the difficulties may indicate the need for further analysis or definition of the purpose. The name long enough to have a certain significance, and short enough to avoid lengthy. The only name in the programming will be used only for the separate district. The strong performance of the title is intended to help people read, therefore, provide the names of people can understand is meaningful. However, please ensure that the choice of language names in accordance with the applicable rules and standards.
The following points are recommended naming method.
- Easily avoid subjective interpretation of arcane names, such as routines for the AnalyzeThis (), or on the xxK8 variables. This will lead to more than the name of justice, and not just abstract.
- In object-oriented languages, in the name of the property type categories are included in the surplus, such as Book.BookTitle. But rather should use Book.Title.
- Use of the verb - term approach to the naming of the implementation of specific objects to the operation of the routine, such as CalculateInvoiceTotal ().
- Heavy allowed in the language function, all heavy-duty should be performing similar functions. For those not allowed to override the language function, a function similar to the establishment of relations between the naming standard.
- As long as appropriate, additional variables were calculated at the end of qualifiers (Avg, Sum, Min, Max, Index).
- In the variable name in the use of complementary right, such as min / max, and begin / end and open / close.
- Given that the majority of names are connected through a number of word structure, please use the case to simplify the format of mixing their reading. Furthermore, in order to help distinguish between variables and routines, the routine use of the name Pascal case processing (CalculateInvoiceTotal), in which each word is the first letter capitalized. The variable name, please use the camel case processing (documentFormatType), which in addition to a word, each word is the first letter capitalized.
- Boolean variable name should contain Is, which means Yes / No or True / False values, such as fileIsFound.
- Named in the state variables, such as the Flag avoid the use of the terminology. Boolean variables state variables different from the place is that it can have more than two possible values. DocumentFlag not use, but the use of a more descriptive name, such as documentFormatType.
- Even for those who may only appear in a few lines of code in a very short period of the survival of the variables, are still using meaningful names. Only use for short cycle Index single-letter variable names, or if i j.
- Do not use the original-original meaning of the numbers, or strings, such as For i = 1 To 7. But the use of named constants, such as For i = 1 To NUM_DAYS_IN_WEEK in order to safeguard and understanding.
- Named in the table, the singular form of the name. For example, Employee, rather than Employees.
- Named in the table column, the table will not repeat the name of, for example, in the table entitled Employee called EmployeeLastName avoid the use of the fields.
- Not included in the list the name of data types. If later it is necessary to change data types, which will reduce the workload.
Microsoft SQL Server
- Not to increase storage process sp prefix, the prefix for identification system stored procedure reservations.
- Not user-defined function to increase fn_ prefix, this prefix is reserved for the built-in functions of the logo.
- Not to extend the process and storage xp_ prefix, the prefix for the identification system to expand storage process reservations.
- Minimize the use of acronyms, but in a consistent manner using the acronym created. There should be an acronym meaning of the same, each abbreviations should be only one initials. For example, if you use the acronym min as a minimum, in all places should do so; min and should not be used as the abbreviation minute.
- In the naming function, including the return value, if a GetCurrentWindowName ().
- And the process of the same document and the name of the folder should also be an accurate statement of their purpose.
- Avoid name reuse different elements, such as the name ProcessSales () routines and called iProcessSales variables.
- Naming elements in the dispute to avoid a homonym of the word (such as write and right), the test code to prevent confusion.
- In naming element, generally avoid using the word misspelled. In addition, the region should be clearly spelled the difference between, such as color / colour and check / cheque.
- Avoid printing markers to identify data types, such as string or $ representatives% representative of integer.
Software documentation exists in two forms: external and internal. External documents (such as norms, help files and design documents) in the external source code maintenance. Internal documents from the developers in the development, the source code in the preparation of the Notes.
Not consider the availability of external files, as hard-copy document may be in the wrong place, the list of source code should be able to exist independently. External document should be standardized, design documents, change requests, the wrong history and use of coding standard component.
Internal documents of a software problem is to ensure that the maintenance and update of the Notes with the source code at the same time. Notes despite correct source code at runtime without any purpose, but for the need to preserve particularly complex or cumbersome software developers who are fragments of it is priceless.
The following points are recommended Notes:
- If C # to develop, use XML document function. For more information, please see: XML documents.
- Revised code, the code is always around the Notes kept up to date.
- At the beginning of each routine, standard samples of the Notes as to the use of routines, assumptions and limitations useful. Notes samples should explain why it is there and can do a brief presentation.
- Avoid the lines of code added to the end of the Notes; Notes end-of-line code harder to read. However, in a statement endorsed variables, it is appropriate to the end of the Notes; In such circumstances, the Notes will be the end of all firms located in the public tabulation alignment.
- Avoid the mess of notes, like the whole planet. But should use the same code blank Notes will be separate.
- Notes avoid the block around the printing frame. This may seem very pretty, but difficult to maintain.
- Prior to deployment, remove all temporary or irrelevant comments, in order to avoid future confusion in the maintenance work.
- If you need to explain complex with the Notes section of the code, please check the code to determine whether it should be rewritten. Notes do everything possible not hard to understand the code, and it should be rewritten. Despite the general should not be to make the code more simple to use at the expense of people's properties, but must be maintained between the performance and maintainability of the balance.
- Notes used in the preparation of a complete sentence. Notes code should be clarified, and we should not increase the ambiguity.
- In the preparation of notes on the code, because the future is likely did not have time to do so. In addition, if they had a chance to review the code has been prepared, seems very obvious things might not six weeks after apparent.
- Avoid unnecessary or inappropriate for the Notes, if not the main humorous note.
- Notes to explain the use of the code's intent. They should not be used as code online translation.
- Notes code is not very clear any content.
- In order to prevent the problem recurring, bug fixes and solutions code always use Notes, especially in a team environment.
- By the logic of recycling and the use of the code branches of the Notes. These are source code readers to help the main aspects.
- Throughout the application, the use of punctuation with the same style and structure of the unified structure to the Notes.
- Notes will be used with blank separators Notes separate. Color tips in the absence of circumstances Show Notes, the Notes will do so very obvious and easy to be found.
Sometimes when to withdraw an object, it needs to complete some operations. For example, if an object being handled by the non-Java resources, such as document or window handles font characters, then you have to recognize an object was withdrawn in the past to ensure that those resources were released. To deal with such a situation, as provided Java ending (finalization) mechanism. You can use the mechanism of the definition of special operations, these operations will be targeted in a garbage recycling procedures to be released at the implementation.
Give a completion of increase (finalizer), as long as your definition finalize () method can be. Java recovery of such an object, then they will call this method. In finalize () method, you must specify an object was withdrawn before the implementation of the operation. Refuse to cyclical recovery operation, the subject is no longer running quote or indirectly, through other object reference. On the subject was released before the Java runtime system calls the object's finalize () method.
Finalize () method of a common format are as follows:
Protected void finalize ()
/ / Finalization code here
The keyword is to prevent such protected from the definition of the code visit finalize () identifier. The identifier, and other identifiers will be explained in Chapter 7.
Understand finalize () is in the garbage collection had previously been called very important. For example, when an object beyond its scope, finalize () not be called. This means that you can not know when - or even whether - finalize () is called. Therefore, you should provide the procedures to the release of other methods used by the target system resources, and can not rely on finalize () to complete the normal operating procedures.
NOTE: If you are familiar with C + +, you know C + + allows you to define a category for a withdrawal of function (destructor), which is targeted to be called before a scope. Java does not support this idea nor withdrawn function. Finalize () method and withdrawal only function close to the function. When you have rich experience of Java, you will see because of the use of Java garbage collection subsystems, and almost no need to use the withdrawal function.
Very often we need to form forms of data into EXECL users in the form of show before, there are several ways to do that, I will introduce a complete use of the ASP method, the method allows the server to create dynamic statements and EXECL not occupy any server space. The method also allows multiple users at the same time receive the data. However, this method requires at least 97 EXECL support.
Nonsense least, it is necessary to complete this work the most important thing is to tell the browser HTTP header, with the following code:
Response.ContentType = "application / vnd.ms-excel"
Below look at an example, assuming that there are now forms of data as follows:
Flavor qty_baked qty_eaten qty_sold price
Boston 24 2 10 0.5
Jelly 24 1 12 0.5
Strawberry 36 1 15 0.5
Chocolate 24 2 6 0.75
Maple 12 1 6 0.75
EXECL customer asked to use the form shown, and I hope that some of them can be calculated together with other summary
With the following code:
Response.ContentType = "application / vnd.ms-excel"
Set conntemp = server.createobject ( "adodb.connection")
Cnpath = "DBQ =" & server.mappath ( "/ stevesmith / data / timesheet.mdb")
Conntemp.Open "DRIVER = (Microsoft Access Driver (*. mdb));" & cnpath
Set RS = conntemp.execute ( "select * from donut")
''% Loop through Fields Names and print out the Field Names
J = 2 row counter''
For i = 0 to RS.Fields.Count - 1
<TD> <B> <% = RS (i). Name%> </ B> </ TD>
<TD> <B> On Hand (calculated) </ B> </ TD>
<TD> <B> Gross (calculated) </ B> </ TD>
Loop through rows%'', displaying each field
Do While Not RS.EOF
<For i = 0% to RS.Fields.Count - 1
<TD VALIGN=TOP> <% = RS (i)%> </ TD>
<TD> = B <= j%%%>-c <= j%>-d <= j%%> </ TD>
<TD> = D <= j%%%> * e <= j%> </ TD>
J = j + 1
%''Make sure to close the Result Set and the Connection object
<TD> Totals </ TD>
<TD> = SUM (B2: B6) </ TD>
<TD> = SUM (C2: C6) </ TD>
<TD> = SUM (D2: D6) </ TD>
<TD> N / a </ TD>
<TD> = SUM (F2: F6) </ TD>
<TD> = SUM (G2: G6) </ TD>
So that we achieve the objective of users in the browser window to open it a simple operation, but also can be saved to the hard drive on other operations. I will also introduce a use filesystemobject operation method. Please wait. Nonsense least, see code:
<% @ LANGUAGE = "VBSCRIPT"%>
''DSNless connection to Access Database
StrDSNPath = "PROVIDER = MSDASQL; DRIVER = (Microsoft Access Driver (*. mdb)); DBQ =" & Server.MapPath ( "testDB.mdb")
<!–# Include file = "adovbs.inc" -> This document your own COPY
Server.scripttimeout = 1000
Response.Buffer = True
If (Request.Form ( "ReturnAS") = "Content") then
Response.ContentType = "application / msexcel"
Response.Expires = 0
Set oConn = Server.CreateObject ( "ADODB.Connection")
Set oRS = Server.CreateObject ( "ADODB.Recordset")
BuildSQL strSQL = ()
ORS.Open strSQL, strDSNPath, adOpenForwardOnly, adLockReadOnly, adCmdText
<! DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.0 Transitional / / EN">
Eclipse multi-lingual package is not only the Chinese translation of Eclipse, but also contains several other major language translation, Eclipse Windows operating system can automatically according to choose the language environment in the use of language-a language that, very intelligent .
Eclipse from the official website (www.eclipse.org) Download 3.0.1 version of the Eclipse corresponding multi-lingual package (page on the English name for Language Pack). Download specific Address: http://download.eclipse.org/downloads/.
Installation method is as follows:
(1) Close Eclipse
(2) the language of the download package (ZIP file) decompress, named Language.
(3) Copy this to the directory C: Eclipse directory, copy the whole after the Eclipse directory structure. Note that there is a directory Language Eclipse subdirectories, and then only features, plugins directory.
(4) the establishment of the link-language paper. C: Eclipse under the new name of a directory and links in the directory and create a text file named language.link (Note: arbitrary name), and then join in the language.link line of text in the document:
Path = C: Eclipselanguage (Note: Path separation of the two components carrying anti-ramps)
Note: the wording on the path (1) path = C: / Eclipse / language (using oblique shoulders)
(2) path = language (with a relative path)
After more than four steps, can now restart the Eclipse. Eclipse View start automatically links directory of all the text files, and one path pointing to the Eclipse plug-in loading.
Eclipse of the multi-lingual package is a plug-in Eclipse, its installation method is based on the Eclipse plug-in the installation method. Plugin There are two methods of installation:
Established link documents, multi-lingual package is the installation of this approach;
Plugin document will be directly copied to the corresponding Eclipse plugins, features directory. A
In section 4.1, if not already mentioned in the procedures of the two threads to a reasonable scheduling, output will be unpredictable results, it would require the use of some special ways to effectively control the thread. However, the use of thread priority obviously is not a reliable program, how to ensure that the effective use of resources can ensure that the outcome of the procedure in accordance with the expected output as was correctly?
The introduction of multi-threaded process tends to show unexpected results, it is because in between the threads and threading CPU time slice was not necessarily to the law. Under normal circumstances, when multi-threaded created after the implementation will not, but to achieve a specific purpose effectively scheduling these threads. Java offers a range of control threads ways and means to enable them to make full use of system resources in the premise, but also to ensure that the results of the proceedings in accordance with the requirements of the output and display correctly. These control of the means: a thread wait for the end, the merger threads, thread and set up guard interrupted, such as a thread. Below these controls introduced on January 1 thread means.
In order to be able to better control threads, thread to achieve the reasonable scheduling, it is first necessary to understand the life cycle of threads. To create a thread from the demise of the existence of four states, namely described below.
1 / create state (new Thread)
When a thread is instantiated, it would create a state until the call start () method. When a thread in the creation of the state, it is only an empty thread object, the system does not allocate resources for it. In this state, the thread is not live (alive).
To create a thread to the state, through the implementation to achieve the following statement:
Thread myThread = new MyThreadClass ();
2 / operational status (Runnable)
The creation of the state in the thread, so long as its calling the start () method, it can be entered so that the thread running. When a thread can be in the running, the distribution system for the thread of the system resources it needs, and arrangements for its operation and call threads run () method. At this point all the threads can run with the conditions, but this does not necessarily state thread immediately be executed. This is because the current use of the computer mostly single processor, therefore, if we want to run at the same time in all the threads can be running is impossible. At this time also need Java operating system (JRE) reasonable scheduling strategy can make this state threads to be really CPU. However thread in this state has been regarded as a living (alive) again.
To make threads can be run in the state, through the implementation to achieve the following statement:
3 / non-operational state (Not Runnable)
It can be said that in one of the conditions listed below occur, not running into the threads.
â—† call the sleep () method;
â—† waiting for a condition variable, a thread calls wait () method;
â—† thread in the input-output flow obstruction.
Not running also known as obstructive state (Blocked). Thread obstruction caused many reasons, such as waiting for the news, input and output such as irrational. At this point, even if the processor idle, the system can obstruction in the state of the implementation of these threads, unless the destruction of obstructive conditions, such as: sleep at the time, be used after the variable conditions notify () or notifyAll () method awakened waiting in one or all threads, the need for access to the I / O resources. These methods will be carried out on the back. In this state, the thread is alive and is regarded as the.
4 / demise of state (Dead)
Generally speaking, the threads run () method implementation at the end of the thread to be considered as entered the demise of the state. In a state of demise of the other threads can not re-enter the state, even if it calls start () method is of no avail. Two methods can be threaded into the disappearance of the state: the natural withdraw (thread implementation End) or forcibly suspended (for example, called the Thread of the stop () method). It should be stated that the stop () method belongs to an earlier version of Java, it is now no longer as a reservation to use the method, therefore, is to terminate a thread, and the need to achieve by other means, such as the interrupt (). This method will be described in section 4.4.
Figure 4.3.1 below depicts the creation of the threads from the demise of the entire process, readers can combine the analysis of the front of each stage to grasp the threads of the life cycle.
Thread understanding of the life cycle to better control thread is helpful, because each thread can be controlled to a designated state, thus completing a specific task. But also because of the improper use of methodsè€Œä½¿thread performance more difficult to predict the outcome, for example, to bring a dormant waiting for the thread, however, such as its end. This requires not only the life cycle of the threads have a good understanding, but also to call the correct method to control the thread. A section on this thread of control: how to wait for the end of a thread.
In the real problem domain, it is possible to wait for the implementation of a thread running beyond the end of another thread, then the Java can be used two ways to achieve this function.
(1) of the calling thread isAlive () method and sleep () method to wait for a certain thread or the end of
The following example creates two threads, and were followed by two right triangle output.
/ / Cases 4.3.1 ThreadTestDemo.java
Class NewThread implements Runnable
Public void run () / / Heavy run method
System.out.println (Thread.currentThread (). GetName ());
For (int count = 1, row = 1; row <20; row + +, count + +)
For (int i = 0; i <count; i + +)
System.out.println () / / End show after-party Output
Public static void main (String  args) / / create two threads
NewThread n = new NewThread ();
Thread t1 = new Thread (n, "thread1");
Thread t2 = new Thread (n, "thread2");
Title asked to run a thread t1, the output of a right triangle, and then wait for the termination of a thread after thread running second t2, then output a right triangle. The actual operation was the outcome? Compile and run this program, we will find that the actual operation is not the result of the two right triangle, but some messy "*" OK, some long, some short. Why? Obviously, because the threads and did not follow the expected call to implement the order, but had a thread running phenomenon. It has been mentioned many times in fact, Java is not in control of any circumstances it is impossible to carry out the order in accordance with the calling thread, but the implementation of the turn. If in order to get the desired results, we need these two threads to be properly controlled so that the first thread to implementation, and determine whether a thread has been terminated, if terminated, then call a second thread implementation.
S1AS7 the relevant documents on the temporary lack of support for the description of Informix database, introduced in the following configuration S1AS7 Informix in the relevant steps for reference.
1. Downloaded from the relevant site Informix type 4 driver package.
Http://www14.software.ibm.com/webapp/download/product.jsp?cat=data&fam=&s=c&id=MBEN-4ZKP2T&pf=&k=&q=&dt=&v=&e=&rs=&c=&sr=1&S_TACT = & & S_CMP presb = n = & type = & t = n postsb
2. Driver running the setup program for installation, the installation is complete, confirmed in the lib directory jar the following documents:
3. Start S1AS7 and entered the admin console
4. Choice examples used by the server "JVM Settings"
5. "Path Setting" and "Classpath Suffix" increase his party:
/ Ifxjdbc.jar: /
6. Preservation, and choose "apply changes"
7. Choice admin console "JDBC" -> "Connection Pools" settings, the creation of a new resources, such as:
JNDI name: infPool
Datasource classname: com.informix.jdbcx.IfxDataSource
Properties needed (adjust the property values as necessary for your install):
8. Select "JDBC" -> "JDBC Resources", the creation of a new resources, such as:
JNDI name jdbc / inf (This is the one to use in lookup ())
Pool name infPool
9. Preserved examples of change and restart the server.
10. Application procedures visit Informix data sources:
DataSource ds = (DataSource) ctx.lookup ( "jdbc / inf");
Will be two apache tomcat server as a front-end for client request and forwarding server reponse.
Apache Address: 10.194.0.131
Tomcat server Address: 10.11.1.29,10.11.1.2
Configuration steps are as follows:
First, download a new version of the Apache Tomcat Connector 18.104.22.168 and 2.0.54 source code, compile and install Apache and Connector:
1. Apache source directory run BuildConf, Configure - prefix = / usr/local/Apache2.0.54, make, make install will be installed Apache / usr/local/Apache2.0.54 directory.
2. Connector source code directory jk / native / running BuildConf, Configure - with-apxs = / usr/local/Apache2.0.54/bin/apxs, make, make install, mod_jk.so installed into / usr / local / Apache2.0.54/modules directory.
Second, apache configuration:
1. Configuration properties file workers: apache establishment of the conf directory workers.properties document, as follows:
Ps = / = worker1 worker.list, jvm1worker.worker1.port = 8009worker.worker1.host = 10.11.1.29worker.worker1
. Ajp13worker.worker1.socket_keepalive type = = trueworker.jvm1
. 8009worker.jvm1.host port = = 10.11.1.2worker.jvm1
. Type = = true ajp13worker.jvm1.socket_keepalive
2. Httpd.conf configuration:
LoadModule part in the configuration by adding a content:
LoadModule jk_module modules / mod_jk.so # Where to find workers.propertiesJkWorkersFile / usr/local/apache2.0.54/conf/workers.properties # Where to put jk logsJkLogFile
/ Usr/local/apache2.0.54/mod_jk.log # Set the jk log level [debug / error / info] JkLogLevel
Info # Select the log formatJkLogStampFormat
"[% A% b% d% H:% M:% S% Y]" # JkOptions indicate to send SSL KEY SIZE, JkOptions
+ + ForwardKeySize ForwardURICompat-ForwardDirectories # JkRequestLogFormat set the request format JkRequestLogFormat "% w% V% T"
VirtualHost configuration in the following:
NameVirtualHost *: 80
ServerAdmin webmaster @ demo
DirectoryIndex index.jsp index.html
JkMount / * worker1
ServerAdmin webmaster @ print
JkMount / * jvm1
3, configuration tomcat:
1. 10.11.1.29 amend the document server.xml:
2. 10.11.1.2 amend the document server.xml:
Can be configured with the same number of tomcat as a number of web application server, and use apache load balancing features, has achieved the same web application between multiple server load balancing, improved web access efficiency. In this paper, in the example of this did not materialize. Everyone to try it according document.