WEB application reads configuration files
Abstract: WEB application reads configuration files
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width="681" border="0"> <tr> <td width = " 397 ">
Suppose you Proxool.properties document attributes in the database configuration information:
Jdbc-0.proxool.alias = Access
Jdbc-0.proxool.driver-class = sun.jdbc.odbc.JdbcOdbcDriver
Jdbc-0.proxool.driver-url = jdbc: odbc: cwb
Jdbc-0.proxool.maximum-connection-count = 20
Jdbc-0.proxool.prototype-count = 4
Jdbc-0.proxool.house-keeping-test-sql = select CURRENT_DATE
Jdbc-0.proxool.verbose = true
Jdbc-0.proxool.statistics = 10s, 1m, 1d
Jdbc-0.proxool.statistics-log-level = ERROR
You attribute this document will be placed on your application's WEB web-info/classes directory, or in the bean category in the document to visit the traditional methods of document attributes Wuguo so:
</ Td> <td width="274">
</ Td> </ tr> </ table>
Package examples; import java.io. *; import java.util .*; public class EnvironmentConfig (static EnvironmentConfig ec; / / Create Object ec private static Hashtable register = new Hashtable ();// static object initialized [in other Before object] private EnvironmentConfig () (super ();) / ** * EnvironmentConfig made an example of * @ return ec * / public static EnvironmentConfig getInstance () (if (ec == null) ec = new EnvironmentConfig (); / / create EnvironmentConfig target return ec; / / return EnvironmentConfig target) / ** * * @ read configuration files * @ param java.lang.String fileName return Properties * / public Properties getProperties (String fileName) (/ / transmission configuration file path InputStream is = null; / / definition of input streams is Properties p = null; try (p = (Properties) register.get (fileName); / / fileName stored in a HashTable / ** * If it is empty Try entered into documents * / if (p == null) (try (is = new FileInputStream (fileName); / / create input streams) catch (Exception e) (if (fileName.startsWith ("/")) / / use getResourceAsStream () method used to locate and open external documents. EnvironmentConfig.class.getResourceAsStream is = (fileName); else is EnvironmentConfig.class.getResourceAsStream ("/"+ = fileName);) p = new Properties (); p.load (is); / / load the input flow register. put (fileName, p) / / stored in its cache is.close ();// HashTable closed input flow)) catch (Exception e) (e.printStackTrace (System.out);) return p; / / Properties returned to the object) / ** * insert description. * Create Date: (2003-8-10 12:30:09) * @ param fileName java.lang.String * @ param strKey java.lang.String * / public String getPropertyValue (String fileName, String strKey) (Properties p = getProperties (fileName); try (return (String) p.getProperty (strKey);) catch (Exception e) (e.printStackTrace (System.out);) return null;))
Below are the jsp test: testpro.jsp
<% @ Page contentType = "text / html; GBK charset ="%>
<% @ Page import = "examples.EnvironmentConfig"%>
<% @ Page import = "java.util .*"%>
Test configuration file
<%
EnvironmentConfig ec = EnvironmentConfig.getInstance ();
/ / Properties p = ec.getProperties ( "/ Proxool.properties");
String s = ec.getPropertyValue ( "/ Proxool.properties", "jdbc-0.proxool.driver-class");
Out.println ( "jdbc-0.proxool.driver-class =" + s);
%>
The result:
Test configuration file
Jdbc-0.proxool.driver-class = sun.jdbc.odbc.JdbcOdbcDriver
Function TempSave (ElementID) (CommentsPersistDiv.setAttribute ( "CommentContent" document.getElementById (ElementID). Value); CommentsPersistDiv.save ( "CommentXMLStore");) function Restore (ElementID) (CommentsPersistDiv.load ( "CommentXMLStore"); document . getElementById (ElementID). CommentsPersistDiv.getAttribute value = ( "CommentContent");) </ td> </ tr> <tr>
↑ Back
In the web application configuration HSQL database
Abstract: In the web application configuration HSQL database
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> Thunder read some forum database, which is used HSQL database. (Please download my entire directory test)
First, download from http://hsqldb.sourceforge.net/ HSQL1.7.3, which will be copied to your hsqldb.jar web applications WEB-INF/lib directory. Write a document lightningboard.properties attributes, data will be stored in your web application TestHsql / hsqldb / lb_db under.
<table Width="681" border="0"> <tr> <td width="392"> # Database — —
DB.DRIVER = org.hsqldb.jdbcDriver
DB.URL = jdbc: hsqldb: webapps / TestHsql / hsqldb / lb_db
DB.USER sa =
DB.PASSWORD =
DB.MAX_CONNECTIONS = 30
Second, write configuration files used to read the above configuration database
Package lightningboard;
Import java.util.Properties;
Import java.io.InputStream;
Import java.io.IOException;
/ **
* LightningBoard configuration, the configuration file:
* "/ Lightningboard.properties."
* @ Version 0.3.5
* @ Author Xiaobo Liu
* /
</ Td> <td width="279" valign="top"> </ td> </ tr> </ table>
(Public class Configuration
Private Properties properties;
Private final static Configuration cfg = new Configuration ();
Private Configuration () (
Properties = new Properties ();
InputStream is = null;
Try (
Is = getClass (). GetResourceAsStream ( "lightningboard.properties");
Properties.load (is);
) Catch (Exception exception) (
System.out.println ( "Can't read the properties file.");
Finally ()
Try (
If (is! = Null)
Is.close ();
) Catch (IOException exception) (
/ / Ignored
)
)
)
Public static Configuration getInstance () (
Return cfg;
)
Public String getValue (String key) (
Return properties.getProperty (key);
)
)
Third, the database connection management, from a simple connection pool access connections.
Package lightningboard.db;
Import java.util.Vector;
Import java.sql.DriverManager;
Import java.sql.Connection;
Import java.sql.SQLException;
Import lightningboard.Configuration;
/ **
* Database Connection Manager
* @ Version 0.3.5
* @ Author Xiaobo Liu
* /
(Public class DBConnectionManager
Private final static DBConnectionManager instance = new DBConnectionManager ();
Private DBConnectionPool pool;
/ **
* Use singleton pattern, only return one instance of DBConnectionManager.
* @ Return DBConnectionManager
* /
Public static DBConnectionManager getInstance () (
Return instance;
)
/ **
* Get a connection
* @ Return Connection
* @ Throws SQLException this method
* /
Public Connection getConnection () (throws SQLException
Return pool.getConnection ();
)
/ **
* Free a connection
* @ Param con connection
* @ Throws SQLException this method
* / Public void freeConnection (Connection con) throws SQLException (
Pool.freeConnection (con);
)
Private DBConnectionManager () (
Init ();
)
Private void init () (
Configuration cfg = Configuration.getInstance ();
String db_driver = cfg.getValue ( "DB.DRIVER");
String db_url = cfg.getValue ( "DB.URL");
String db_user = cfg.getValue ( "DB.USER");
String db_password = cfg.getValue ( "DB.PASSWORD");
Int db_maxConn = Integer.parseInt (cfg.getValue ( "DB.MAX_CONNECTIONS"));
Try (
Class.forName (db_driver);
)
Catch (ClassNotFoundException ex) (
System.out.println (ex);
)
Pool = new DBConnectionPool (db_url, db_user, db_password, db_maxConn);
)
/ / Inner class
(Class DBConnectionPool
Private Vector freeConnections = new Vector ();
Private int maxConn;
Private int connNumb;
Private String URL;
Private String password;
Private String user;
Public DBConnectionPool (String URL, String user, String password, int maxConn) (
This.URL = URL;
This.user = user;
This.password = password;
This.maxConn = maxConn;
)
Public synchronized void freeConnection (Connection con) (
FreeConnections.addElement (con);
ConnNumb -;
NotifyAll ();
)
Public synchronized Connection getConnection () (throws SQLException
Connection con = null;
If (freeConnections.size ()> 0) (
Con = (Connection) freeConnections.firstElement ();
FreeConnections.removeElementAt (0);
Try (
If (con.isClosed ()) (
Con = getConnection ();
)
)
Catch (SQLException e) (
Con = getConnection ();
)
)
Else if (maxConn == 0 | | connNumb <maxConn) (
Con = newConnection ();
)
If (con! = Null) (
ConnNumb + +;
)
Return con;
)
Private Connection newConnection () (throws SQLException
Connection con = DriverManager.getConnection (URL, user, password);
Return con;
)
)
)
4, the following is the test jsp documents: Testhsql.jsp, Testhsql1.jsp (download)
<% @ Page contentType = "text / html; GBK charset ="%>
<% @ Page language = "java" import = "java.sql .*"%>
<% @ Page import = "lightningboard.db.DBConnectionManager"%>
<%
DBConnectionManager dbcm = DBConnectionManager.getInstance ();
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
String sql = null;
Try (
Conn = dbcm.getConnection ();
/ / If there Table user to delete
Sql = "DROP TABLE IF EXISTS user";
Ps = conn.prepareStatement (sql);
Ps.executeUpdate ();
/ / Create Table
Sql = "CREATE TABLE USER (ID INTEGER, NAME VARCHAR (50), MOBILE CHAR (12))";
Ps = conn.prepareStatement (sql);
Ps.executeUpdate ();
/ / Insert data
Sql = "INSERT INTO user VALUES (?,?,?)";
Ps = conn.prepareStatement (sql);
Ps.setInt (1, 1);
Ps.setString (2, "San");
Ps.setString (3, "13912345678");
Ps.executeUpdate ();
/ / Data enquiries
Ps = conn.prepareStatement ( "SELECT * FROM user");
Rs = ps.executeQuery ();
While (rs.next ()) (
Out.println ( "ID:" + rs.getInt ( "id") + "
");
Out.println ( "Name:" + rs.getString ( "name") + "
");
Out.println ( "mobile phone number:" + rs.getString ( "mobile"));
)
)
Finally (
If (rs! = Null)
Rs.close ();
If (ps! = Null)
Ps.close ();
If (conn! = Null)
Conn.close ();
)
%>
OK!! Function TempSave (ElementID) (CommentsPersistDiv.setAttribute ( "CommentContent" document.getElementById (ElementID). Value); CommentsPersistDiv.save ( "CommentXMLStore");) function Restore (ElementID) (CommentsPersistDiv.load ( " CommentXMLStore "); document.getElementById (ElementID). CommentsPersistDiv.getAttribute value = (" CommentContent ");) </ td> </ tr> <tr>
↑ Back
Struts configuration file on-config.xml
Abstract: Struts configuration file on-config.xml
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle">
Struts is the core of struts-config.xml configuration file, in this document describes all the Struts components.
Here configuration including major and minor components of the components, struts-config.xml Below are the main elements include:
First, struts-config.xml the main elements:
<? Xml version = "1.0" encoding = "ISO-8859-1">
Struts-config PUBLIC "- / / Apache Software Foundation / / DTD Struts Configuration 1.1 / / EN"
"Http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<table Width="676" border="0"> <tr> <td width="391"> type=â€fully qualified class name of FormBean”/> Function TempSave (ElementID) (CommentsPersistDiv.setAttribute ( "CommentContent" document.getElementById (ElementID). Value); CommentsPersistDiv.save ( "CommentXMLStore");) function Restore (ElementID) (CommentsPersistDiv.load ( "CommentXMLStore"); document . getElementById (ElementID). CommentsPersistDiv.getAttribute value = ( "CommentContent");) </ td> </ tr> <tr>
↑ Back Abstract: Jbuilder7 + weblogic6.X configuration : Win 2000 Temp, Tmp configuration Because we generated ejb related to a series of code compiler, then the temporary files generated there will be a local release ah, but in the Temp Win2000, Tmp directory chooses spaces such as% USERPROFILE% \ Local Settings \ Temp, Next we have to configure to: 1) Right-click "My Computer" election attributes, in the pop-up dialog box select the "Advanced" and then choose "Environment Variables" button, 2) Revise the "Administrator of the user variable" and the "system variables" in the TEMP, TEMP, TMPDIR options, click each option, then "Edit" (right), each variable called TEMP, TEMP , the values are changed TMPDIR c: \ WINNT \ temp, of course, this is not necessary, but I suggest that you do so. In fact, had no difficulty, if diverted End, Win2000 environment so should be no problem. First, JDBC Connection Pool to the configuration database as an example of small Mysql In this configuration before the first to use the database JDBC Driver Jar files on D: \ bea \ wlserver6.1 \ lib \ jdbc directory (recommendation to do so, not on building a directory jdbc hymns), and then edit D: \ bea \ wlserver6.1 \ config \ mydomain under startWebLogic.cmd documents in the classpath adding database JDBC Driver documents, such as the Scarlet Letter: : RunWebLogic This Weblogic will start loading to the use of the database JDBC driver, configuration also will be normal, otherwise they will be in error. 3) Fill each of the parameters, as follows: url: jdbc: mysql: / / 127.0.0.1:3306 / test 1) In order Weblogic console launched Services \ JDBC \ Tx Data Sources Jndi name: MysqlDataSoruce JBuilder 7, in the relevant configuration A database-driven loading Weblogic with the same, in this configuration before the first to use the database JDBC Driver Jar files on D: \ JBuilder7 \ lib \ jdbc directory (recommendation to do so, not on building a directory jdbc hymns) 1) Open JBuilder 7, click Tools \ EnterPrise Setup ……. 2) In the pop-up window, select signed Database Drivers In this configuration prior to installation of Borland Enterprise Servler 5.02, also 4.5% IAS, Talia is one thing, of course, that I am a new not old, the installation process slightly, because it is very easy to install! Basically all the way round , I put my installed in the D: \ BorlandEnterpriseServer made. 1) Open JBuilder 7, click Tools \ EnterPrise Setup ……. 2) Select CORBA signed in the Configuration under the drop-down list box, select VisiBroker 3) Choose Edit …, the pop-up window click Edit Confiuration path for orb tools 5) re-twice OK, JBuilder also ask you to restart, no way, as it said so, the resumption JBuilder. 6) After the restart, but also to Tools \ EnterPrise Setup ……., CORBA of the election, the election Edit, in the pop-up window select Library for projects: next to the button … 13) then select Custom signed, in accordance with the following configuration shown in red, could you Weblogic directory with the location and I are different, but the meaning is probably the same. Bill-switched from: csdn Abstract: J2ME configuration layer depth Abstract: j2me configuration problems J2me configuration problems Abstract: Spring XML configuration skills Spring 12 is a procedural framework for strong java, java is widely used in the process. It used POJO provide enterprise-class services. Spring use dependency injection can be simple and … Spring XML configuration of the 12 skills
Spring is a powerful procedural framework for java, java is widely used in the process. It used POJO provide enterprise-class services. Spring use dependency injection can be simple and effective testing capabilities. Spring beans, dependencies, and services required by the bean will be in the configuration described in the document, configuration files generally use the XML format. However XML configuration file lengthy and difficult to use, you use a lot of bean of a large project in which it would become difficult to read and control. In this article I will give you a display of 12 kinds Spring XML configuration files relating to the best skills. Some of them have more meaningful, and not just the best skills. Please note that other factors, such as domain model design, will affect XML configuration, but this article more concerned about the readability of the XML configuration and can be manipulative. 1. Avoid the use of automatic assembly Spring bean category through self-reflection to rely on the automatic assembly, so you do not have a clear description of the attributes or bean constructor function parameters. According to the attribute name live match types, bean attributes can be automatically assembled. The constructor function can match type automatic assembly. You can even set up automatic assembly for automatic detection, this Spring for you will choose an appropriate mechanism. Look at this example: Spring bean category through self-reflection to rely on the automatic assembly, so you do not have a clear description of the attributes or bean constructor function parameters. According to the attribute name live match types, bean attributes can be automatically assembled. The constructor function can match type automatic assembly. You can even set up automatic assembly for automatic detection, this Spring for you will choose an appropriate mechanism. Look at this example: <Bean id = "orderService" Class = "com.lizjason.spring.OrderService" Autowire = "byName" /> OrderService class attributes and containers were used in the example of a bean match. Automatic assembly will be the preservation of some quiet types of information and reduce confusion. However, it will be sacrificed because of this configuration intuitive and maintainability, you will be in the actual project will not use it. Many guides and presentation materials touted as the Spring regarded it a very cool features, but did not mention it this shortcoming. In my view, as the object of Spring Pond, it has more commercial flavor. It seems to XML configuration files can be more streamlined, but in fact has increased its complexity, especially in your larger projects already defined in a lot of the time especially bean. Spring allows you to mix the use of automatic and manual assembly, but such contradictions would XML configuration of the more puzzling. 2. Use named norms And the concept of Java code, used in the project has always been clear, descriptive, normative consensus on the naming of developers understand XML configuration very useful. With bean ID, for example, you can follow the Java class attribute the naming norms. For instance, the bean ID OrderServiceDAO should orderServiceDAO. For large projects, in the bean ID front of a packet as a prefix. 3. The use of simplified format Simplified format conducive to reducing redundancy, as it attribute values and cited as an attribute, not an element. Look at the following example: <Bean id = "orderService"
Class = "com.lizjason.spring.OrderService">
<property Name="companyName">
<value> Lizjason </ value>
</ Property>
<constructor-arg>
<ref Bean="orderDAO">
</ Constructor-arg>
</ Bean>
Above procedures can be re-written to simplify the format: <Bean id = "orderService"
Class = "com.lizjason.spring.OrderService">
<Property name = "companyName"
Value = "lizjason" />
<constructor-arg Ref="orderDAO"/>
</ Bean>
Simplified format in the 1.2 version has been available, but please note does not exist <ref local ="…"> this format can not only simplify your code less input, and the XML configuration can be more clear. When your configuration file in a large number of bean definition, it can significantly enhance readability. 4. Make full use of index type rather than to solve the structural problem of the matching function parameters When the constructor function in a number of the same type of parameters, Spring allows you to use only the beginning of the index from 0 or value labels to solve this problem. Look at this example: <Bean id = "billingService"
Class = "com.lizjason.spring.BillingService">
<constructor-arg Index="0" value="lizjason"/>
<constructor-arg Index="1" value="100"/>
</ Bean>
It is best to use the type attribute replace the above practices: <Bean id = "billingService"
Class = "com.lizjason.spring.BillingService">
<Constructor-arg type = "java.lang.String"
Value = "lizjason" />
<constructor-arg Type="int" value="100"/>
</ Bean>
Can be used index slightly reduce redundancy, but it is more prone to error than type attributes and high readability. You should only function in the structure of the conflict in the use of index. 5. If possible, as far as possible reuse bean definition Spring provides a mechanism similar to the succession of configuration information to reduce duplication and XML configuration much more simple. A subset of bean from its parent bean inheritance configuration information, in essence, the father of the bean-bean like it's a template. This is a large-scale project to use features. All you have to do is the father of abstract bean attributes for the true home, and in the sub-bean quoted. For example: <Bean id = "abstractService" abstract = "true"
Class = "com.lizjason.spring.AbstractService">
<Property name = "companyName"
Value = "lizjason" />
</ Bean>
<Bean id = "shippingService"
Parent = "abstractService"
Class = "com.lizjason.spring.ShippingService">
<property Name="shippedBy" value="lizjason"/>
</ Bean>
ShippingService bean inherited abstractService bean attribute values lizjason companyName. Note that if you name a class or bean factory method, this bean will be the default for the abstract 6. Make full use of ApplicationContext assembly bean, and not import Ant scripts like imports, the import elements for the Spring bean modular assembly is very useful, for example: <beans>
<import Resource="billingServices.xml"/>
<import Resource="shippingServices.xml"/>
<Bean id = "orderService"
Class = "com.lizjason.spring.OrderService" />
<beans>
However, the use of XML than in the pre-assembly of these bean imports, the use of ApplicationContext to configure they will be more flexible and allow more of the XML configuration easier to manage. Below this, as you can send a bean definition of the array to ApplicationContext constructor: String [] = serviceResources ( "OrderServices.xml" "BillingServices.xml" "ShippingServices.xml"); ApplicationContext orderServiceContext = new ClassPathXmlApplicationContext (serviceResources); 7. Id used to identify bean You can use the name or id as a bean logo. Id with poor readability, but it can influence the XML parser so that the reference bean effective. If id as XML IDREF bound not be able to use, you can use the name as a bean logo. XML IDREF is bound id must start with the letter (or in the name of an XML punctuation), could be behind the letters, numbers, hyphens, underscores, colon or full stops (do not know how good translation). In practical application will rarely encountered XML IDREF constraint. 8. In the development stage rely on the use of checks You can bean for the dependency-check attribute a value to replace the default none, for instance, simple, objects or all, so you have done for containers will depend on the effectiveness of the inspections. When all the attributes of a bean (or certain attributes directory) have been clearly set, or use automatic assembly will be very useful. <Bean id = "orderService"
Class = "com.lizjason.spring.OrderService"
- Check dependency = "objects">
<Property name = "companyName"
Value = "lizjason" />
<constructor-arg Ref="orderDAO"/>
</ Bean>
In this example, the container will ensure that these properties are not privitives or guarantee collections for orderService bean settings. The bean for all the default settings it is possible to rely on the inspection, but the bean because some of the attributes do not need to set and is rarely used. 9. Configuration file for each plus a description of the Notes XML configuration file in the best use of the id and descriptive name, rather than piles of notes. In addition, a document describing the first increase will be very useful in this description can be summed up in the document definition of bean. Another option, you can add elements in the description description. For example: <beans>
<description>
This file defines billing service
Related beans and it depends on
BaseServices.xml, which provides
Service bean templates …
</ Description>
…
</ Beans>
With a good description of the elements that tools can be very easy to describe the elements of the information from this extracted. 10. Communication and team members change When you modify java source code, to ensure that changes the configuration file in the corresponding part of this situation and inform your team members. XML configuration file is the code, which is an important component of the process, but they very difficult to read and maintain. Most of the time, you need to look at XML configuration files and java code to know is how the case. 11. Setter injection into the function and structure, priority is given to the former Spring provides into three: constructor injection, and injection method setter injection. We generally use the first two. <Bean id = "orderService"
Class = "com.lizjason.spring.OrderService">
<constructor-arg Ref="orderDAO"/>
</ Bean>
<Bean id = "billingService"
Class = "com.lizjason.spring.BillingService">
<Property name = "billingDAO"
Ref = "billingDAO">
</ Bean>
In this example, orderService bean injected with a constructor function, and BillingService bean spent setter injection. Constructor injection can be constructed to ensure that the correct bean, but setter inject more flexibility and easier to control, especially when a number of class attributes and some of them are optional is the case. 12. Not to abuse injection As mentioned earlier, the ApplicationContext Spring can help you create java, but not all java object should be created through an infusion. For example, the domain objects should not be created through ApplicationContext. Spring is an excellent framework, but considering the readability and manipulation of XML-based configuration configuration will be a lot of bean in the definition of time and trouble. Rely on the use of the transition to XML configuration will be injected into the more complicated and lengthy. Remember, when using efficient IDE, such as Eclipse and IntelliJ, java code more easy reading, maintenance and management than the XML file Conclusion Spring is a popular XML format configuration. There are a lot bean definition, XML-based configuration will become lengthy and difficult to use. Spring offers a wealth of configuration options. Appropriate use of these options can make the XML configuration more clear, but a number of other options, such as automatic assembly, may reduce the readability and maintainability. Reference herein referred to these techniques may help you create a clean and easy-to-read XML configuration file Abstract: IIS configuration JSP environment Destination Create table First, we have in our sample database to create a table which COFFEES, included in the cafe sells coffee, the necessary information, including the names of coffee, and their prices this week, the number of pounds sold and the number sold so far. COFFEES table on the future we will be described in detail as follows: COF_NAME SUP_ID PRICE SALES TOTAL Coffee out of the storage is COF_NAME, it is VARCHAR SQL data type, the biggest length of 32 characters. Because we are selling each type of coffee is the use of different names, the name can be used as the sole identification coffee logo, it can be used to decide bond. The second SUP_ID called out for the preservation of coffee supplier logo; its SQL data types INTEGER. Article 3 called PRICE, because it need to preserve minority with a decimal number, it's SQL type FLOAT. (Note that SQL is usually money or DECIMAL NUMERIC type, but there are differences between the different DBMSs, in order to avoid the old version of the JDBC the incompatibility In this tutorial we use more standard FLOAT type) SALES out of SQL type INTEGER , and its value-week sell coffee Bangshu. The last one, TOTAL of SQL type INTEGER, preservation of the coffee sold to date the total Bangshu. The second database table SUPPLIERS, preserving each vendor information: SUP_ID SUP_NAME STREET CITY STATE ZIP COFFEES with SUPPLIERS contain SUP_ID out, it means SELECT statements can be obtained from the two tables of relevant information. SUPPLIERS SUP_ID table is shown in the main keys for the unique identification of each coffee suppliers. In COFFEES table, which are said SUP_ID foreign keys. SUP_ID attention to the value of each SUPPLIERS exterior appeared only once this primary key is essential. In COFFEES exterior, as a foreign key, obviously it can be duplicated SUP_ID value, because the same vendor can provide a variety of coffee. In this section the final, you will see how to use the SELECT statement in the primary key and a foreign key examples. Below the SQL statements used to create COFFEES table. Out with the list box with the SQL type composition. Out (including listing and SQL type) with a between separated by a comma. VARCHAR type definition to create the greatest length, it needs to have a maximum length of the parameter said. Type in the parameters must be behind the brackets. SQL statements are as follows, listed COF_NAME was limited to the length of not more than 32 characters: CREATE TABLE COFFEES These non-DBMS code at the end of sentences, as each may be different DBMS. For example, Oracle uses a semicolon (;), as the end of a statement, and the use of Sybase go. You are the driver will automatically provide the appropriate sentence at the end, so you do not have to include it in your JDBC code. In addition, we should point out that the SQL statement is the format. In the CREATE TABLE statement, the keyword used uppercase characters, and each item is from another party. SQL and no such request only for the purpose of more easily read. SQL standard is no distinction between the words of the case, therefore, as in the case of a SELECT statement can be a variety of wording. So, the following two different wording of SQL statements is the same. SELECT First_Name, Last_Name Select First_Name, Last_Name from Employees where However, the quotes is to distinguish between the contents of the case: in the name W, Washington must be capitalized and the rest of the characters must be lower case. The logo, different DBMS have different requirements, for example, some DBMSs asking those names to be printed and table must be created with the same, and some did not request. For the sake of safety, we all use uppercase logo as COFFEES, SUPPLIERS, because we are so defined them. We only wrote to create the SQL statement COFFEES table. Now we are outside the quotation marks in it (make it a string), and string variables to assign createTableCoffees, JDBC code in the future, we can use this variable. As seen, and DBMS does not care branch, but the Java language, the String object branch is being compiled, however. Thus, we can use the plus (+) to the string connecting every line. String createTableCoffees = + CREATE TABLE COFFEES We in the CREATE TABLE statement data types used in SQL is a common type (also called JDBC type) in their category java.sql.Types definition. DBMSs are usually the type of use of these standards, so when you want to try something JDBC application, you can directly use CreateCoffees.java application, which uses the CREATE TABLE statement. If your DBMS using its own local name of the type that we supply for your other applications, we will be explained in detail in the back. In the use of any application process, of course, we will let you know the basis of JDBC. Create JDBC Statements for the target object Statement SQL statement sent to the DBMS. You only need simple objects to the creation of a Statement and then implement it, the use of appropriate approaches to the implementation of the SQL statement sent you. For the SELECT statement, you can use the executeQuery. To create or modify tables statement, the method used is executeUpdate. Need an active link to create Statement object example. In the example below, we use our Connection object con create Statement stmt object: Statement stmt = con.createStatement (); Stmt this already exists, but it is not the SQL statement sent to DBMS. We need to provide SQL statements as a parameter to provide our use of the Statement of the method. For example, the following code segment, we use the above example as a SQL statement executeUpdate parameters: Stmt.executeUpdate (+ CREATE TABLE COFFEES Because we have to assign a SQL statement createTableCoffees variables, we can write code as follows: Stmt.executeUpdate (createTableCoffees); We use the phrase implementation executeUpdate createTableCoffees is because in the SQL statement is DDL (Data Definition Language) statements. Creating tables, changing table, the table is deleted DDL statements example, we should executeUpdate approach to the implementation. You can also see it in the name of, and methods for the implementation of executeUpdate also update the table and SQL statements. In fact, for the creation of the table, executeUpdate for more time to update the table, because only need to create a table, but often been updated. Maximum use of the implementation of the SQL statement is executeQuery. This method is used to execute a SELECT statement, it is almost used up the SQL statement. Immediately you will see how to use this method. Input data in the table shows how we have through the designated list, data type to create COFFEES table, but it is only the establishment of the structure of the questionnaire. Table does not have any data. We will enter his data to the table to provide information in each column, the attention of the inserted sequence data created with the time table is the same, both default order. The following code to insert a line data, the value of the Colombian COF_NAME, SUP_ID 101, for 7.99 PRICE, SALES 0 TOTAL 0. COFFEES as create table, we create an object Statement and the implementation of executeUpdate methods. Because SQL statements row over, we put it into two lines, and using plus (+) connected. Special attention should be paid to that, in COFFEES between a space and VALUES. This box must be in quotes, and we must COFFEES with VALUES between do not have this space, and SQL statements would be wrong to be read as INSERT INTO COFFEESVALUES … and will be looking for table COFFEESVALUES DBMS. To the attention of the coffee name, we used the single quotes. Statement stmt = con.createStatement (); The following code inserted into the second line in the table COFFEES. We can use Statement for each object without having to create a new implementation. Stmt.executeUpdate (INSERT INTO COFFEES + The remaining firms are as follows: Stmt.executeUpdate (INSERT INTO COFFEES + Data obtained from the table since the table COFFEES already have data, we will be able to write a SELECT statement to obtain these values. The following SQL statement in the asterisk (*) indicates select all out. Because there is no WHERE clause to limit the use of the firms selected, the following SQL statement choice for the whole table. SELECT * FROM COFFEES The result is the entire table of data, as follows: COF_NAME SUP_ID PRICE SALES TOTAL If you directly in the database system, SQL query input, you will see on your terminal above results. When we pass a Java application access to a database, as we do the same soon, we need to search results so that we can use them. You will see how to achieve in the next section. This is another example of the SELECT statement, which will be priced per pound of coffee and their respective list. SELECT COF_NAME, PRICE FROM COFFEES Set the results of inquiries will be of the following forms: COF_NAME PRICE SELECT statements made above all the names and the price of coffee. And the following SELECT statements limit price less than $ 9.00 per pound of coffeeæ‰è¢«choice. Result set will be of the following forms: COF_NAME PRICE ↑ Back Abstract: Tomcat5 data source configuration mysql4 <tr> <td>
A configuration environment variable: WindowsXP sp2 + Path: tomcat5 in the C: \ Tomcat 5.5; Path (on the basis of the original): C: \ Tomcat 5.5 \ bin; C: \ jdk1.5.0_01; C: \ jdk1.5.0_01 \ bin; C: \ Tomcat 5.5 \ common \ lib \ servlet-api . jar; C: \ Program Files \ MySQL \ MySQL Server 4.1 \ bin CLASSPATH: C: \ Tomcat 5.5 \ common \ lib \ servlet-api.jar; C: \ Tomcat 5.5 \ common \ lib \ jsp-api.jar JAVA_HOME: \ jdk1.5.0_01 CATALINA_HOME: C: \ Tomcat 5.5 Second, the establishment of test database In the establishment of a mywebdb mysql database, create a table at the same time tested are as follows Create database mywebdb Create table tested Then insert the following two test data Insert into member values (1, "Holmes"); So far, the database ready Third, data source configuration Tomcat5 1 to find TomcatServer admin account login / Service / Host / procedures of your Web / DataSource / / Click here. 2 Select the "Create New Data Source." 3 complete information After saving a certain four points commit changes. 5 do not have to restart, as long as refresh pages. I server.xml says: <? Xml version = "1.0" encoding = "UTF-8"> 4, configure web.xml Web.xml located in the C: \ Tomcat 5.5 \ webapps \ ROOT \ WEB-INF, that is your WEB in the web.xml. (I direct use TOMCAT project were amended) Use the same text editor open the web.xml, and then add the following sentence (in the 5, the preparation of test jsp page In the C: \ Tomcat 5.5 \ webapps \ ROOT prepared a test.jsp, the code below: Javax.naming.Context ctx = new javax.naming.InitialContext (); Stmt = con.createStatement (); Out.print (rs.getInt (1)); 6. Begin testing Operation tomcat, open IE input in the address bar: http://localhost:8080/ROOT/test.jsp. But the result will be displayed, however, is: Cannot create JDBC driver of class''for connect URL 'null' Please expert advice about! Radical!
<form-beans>
<form-bean />
</ Form-beans>
</ Td> <td width="275"> </ td> </ tr> </ table>
Note: The order of the above elements is very important, your struts-config.xml configuration file must be configured in accordance with this order, whether
In your containers will be activated when the error.
Second, the struts-config.xml of elements:
1.
/ Images / smalllogo.gif
/ Images / largelogo.gif
2.
Short textual discription of its parent element
3.
Full-length textual discription of its parent element
4.
It is used to set its parent element in the set JavaBean property value, it tends to be used in designated GenericDataSource attributes,
ActionMappings expansion and the expansion of the global forwards. As follows:
For example:
Third, JDBC data source configuration
Their configurations are as follows:
Property Description Information
Key Binding in the ServletContext DataSource examples of the bond index,
If the default settings for Action.DATA_SOURCE_KEY, if the application in more than one DataSource,
Key should be provided value.
DriverClass used JDBC Driver category (necessary): com.microsoft.jdbc.sqlserver.SQLServerDriver
Url JDBC used by the URL (necessary): jdbc: microsoft: sqlserver: / / xg088: 1433
MaxCount opened at the same time the greatest number of links, the default value of 2 (optional)
MinCount at the same time open the smallest number of links, the default value of 1 (optional)
User link to the database user name (required)
Password link to the database password (necessary)
Description Description of information on the DataSource (optional)
Set ReadOnly If true, then the link is read-only, default is false. (Optional)
Links LoginTimeout create the maximum allowable time, in seconds flat. (Optional)
AutoCommit if it is true, then execute each time after a mandatory rollback. Default is true. (Optional)
For example:
4, configuration FormBean
<form-bean /> Definition will be used to bind to the FormBean Action examples. Grammar as follows:
<form-beans>
<Form-bean name = "name used to uniquely identify a FormBean"
</ Form-beans>
Example:
<form-beans>
<form-bean Name="lookupForm" type="wiley.LookupForm" />
</ Form-beans>
5, the overall configuration can be defined transponders overall number of transponders
If not, then the whole for the allocation of transponders. Grammar as follows:
Apart from the name and path attributes, there are a redirect attributes, if true redirect set when used
HttpServletResponse.sendRedirect () method, otherwise use RequestDispatcher.forward () method, the default is false.
Note: If true to be used HttpServletResponse.sendRedirect () method, then stored in the original HttpServletRequest
The value will be lost.
Examples:
6, configuration
It can be defined several
Name = "the name of the form bean bound to this Action">
Property Description Information
Path in the browser, type the URL of the characters (necessary)
Type link to the mapping of the full name of Action (optional)
Name associated with the operation of the Action Bean In "form-bean /> defined in the name (optional)
Scope of the scope specified ActionForm Bean (session and request), the default for the session. (Optional)
Input t mistake occurred when Bean returned to the control. (Optional)
ClassName designation of a Class Action calls this the ActionMapping class full name. By default
Org.apache.struts.action.ActionMapping, (optional)
Forward designated to deal with the corresponding request of the corresponding JSP pages. (Optional)
If there is no forward Include the time, it has forward role. (Optional)
Validate if it is true, will be called the ActionForm validate () method, it does not call, the default is true. (Optional)
Examples:
Validate = "true"
Input = "/ index.jsp">
7, configuration RequestProcessor
In struts-config.xml file using
Property Description
ProcessorClass specify the definition of the full name of RequestProcessor
BufferSize earmarked for download by the cache size. The default is 4096 bytes.
ContentType definition response text types, the default is the text / html
Debug definition of the current system-level debugging, the default is 0
Locale If it is true, then stored in the user's session Locale target for the true default
MaxFileSize specified the size of the largest download files. The default is 250 M
MultipartClass org.apache.struts.upload.DiskMultipartRequestHandler category designated as a substitute for the full name of the class.
Nocache If it is true, will be closed every response function of the cache. The default is false
TempDir contained on the document designated by the temporary directory. Default values from containers decision
Examples:
â‘
â‘¡
Debug = "3"
Locale = "true"
Nocache = "true"
ProcessorClass = "org.apache.struts.action.RequestProcessor" />
8, configuration Message Resources
In struts-config.xml file using
Property Description
Parameter resources to the full name of the paper
ClassName deal with the definition of categories of information resources the full name, the default is org.apache.struts.config.MessageResourcesConfig
Factory MessageResourcesFactory definition of the full name, the default is
Org.apache.struts.util.property.MessageResourcesFacotry
Key definitions in the resource kit bundled in the ServletContext of the key attributes, the default values are Action.MESSAGES_KEY.
Null if it is true, it could not find key information, then return null, the default is true.
Examples:
â‘
â‘¡
Null = "false" />
Parameter = "StorefrontImageResources"
Null = "false" />
NOTE: The purpose of key settings as follows:
Here that we should StorefrontImageResources.properties resources to find the keys in the document is "navbar.home.image" corresponding to
Value.
Here StorefrontImageResources.properties reads as follows:
……
Navbar.home.image = / images / home.gif
Navbar.home.image.alt = Home
……
Navbar.home.image.alt note here and the same.
9, configuration Plug-in
Plug-in configuration is as follows:
Can also be as follows:
Jbuilder7 + weblogic6.X configuration
WebLogic 6.X part
Echo on
Set PATH = \ bin;. \ Bin \ oci817_8; d: \ oracle \ ora81 \ bin;% PATH%
Set CLASSPATH =. \ lib \ cr_wls60f.jar;. \ Lib \ weblogic_sp.jar;. \ Lib \ weblogic.jar;. \ Lib \ jdbc \ mysql.jar
1) In order Weblogic console launched Services \ JDBC \ Connection Pools
2) Click the Configure a new JDBC Connection Pool …
Driver classname: org.gjt.mm.mysql.Driver
Properties (key = value): user = root
4) Do not forget to click Apply to that application:)
5) Connections signed by the initial capacity, the largest capacity, growth capacity can be configured according to their own needs
6) also critical final step, we have done the above configuration has not been applied to Weblogic, so step worse,
Targets signed the election, the election Servers signed, the election Available (available) in the myserver, and then "," Application of a further point Apply.
In this way we will be doing the work truly effective, Weblogic also be aware that we configuration JDBC Connection Pool
Second, configuration data sources
2) Click the Configure a new JDBC Tx Data Source …
3) Fill each of the parameters, as follows:
PoolName: MysqlPool
Row prefetch size: 48
Stream chunk size: 2564) do not forget to click Apply to that application:)
5) Similarly, the election Targets signed, signed Servers election, the election Available (available) in the myserver, and then "," Application of a further point Apply.
In this way we will be doing the work truly effective, Weblogic also be aware that we configuration DataSource.
3) Add another point button, the pop-up a new window (perhaps you on the map with a slightly different)
4) New … then click the button, the pop-up a new window, and change the Name: The default value for mysql (as long as meaningful, what were all from 10%)
5) Click the Add button to find … and add database JDBC Driver, of course, we go to the D: \ JBuilder7 \ lib \ jdbc go under the election mysql.jar, careful not to mysql.jar start, as Figure selected as a click OK on the trip.
Note: will be compatible with the Shift and Ctrl keys at the same time a number of elections. Jar files.
6) The results are as follows map, if there are multiple needs added. Jar file, but also points to add Add … button.
7) OK exit.
OK again, mysql JDBC driver has been added.
9) Once again, the Ok, JBuilder tips from the emphasis will be effective only after the above configuration, and to identify and restart JBuilder.
Second, EJB 2.0 and the application server configuration, as an example to WebLogic 6.X
4) Click Path for ORB tools: Read the next button, the pop-up Select Directory window, select D: \ BorlandEnterpriseServer5 \ bin and OK.
7) In the pop-up a new window for the User Home in you will find one more option Borland Enterprise Server 5.0.2 + Client
That is shown in Figure Heiliang choice options, and then three times out OK.
Select Project \ Default Project Properties of
9) In the dialog box select Server shells signed Figure, click the button …,
10) In the new pop-up dialog box, select the WebLogic Application Server 6.x +, and then check Enable server, see figure in Hong Kuang.
11) check Enable server, or other various options to fill, click the button …,
Select Home directory;
Working directory selection;
For your machine installed Weblogic position.
12) signed the Class click the Add button, the above chart will be D: \ bea \ wlserver6.1 \ lib \ cr_wls60f.jar add documents come. As Figure red.
Reuse Move Up button will be D: \ bea \ wlserver6.1 \ lib \ cr_wls60f.jar most of the documents moved to end, the general added. Jar in the document below.
This step also more important, because in the JBuilder environment can be directly activated Weblogic, that it will begin testing license is legitimate, that is, whether there cr_wls60f.jar document.
After the allocation, Click on the OK button to withdraw from
Domain name: mydomain
Server name: myserver
Version: 6.1 Service Pack1 (d: / bea/wlserver6.1)
14) to the window in Figure Single server for all services in project the drop-down list box, select WebLogic Application Server 6.x + As shown, then OK exit.
15) At this point JBuiler 7 with the completion of the allocation of WebLogic 6.x
Java, java, J2SE, j2se, J2EE, j2ee, J2ME, j2me, ejb, ejb3, JBOSS, jboss, spring, hibernate, jdo, struts, webwork, ajax, AJAX, mysql, MySQL, Oracle, Weblogic, Websphere, scjp, scjd
↑ Back J2ME configuration layer depth
Java 2 Micro Edition (J2ME), is built on a profiles, configuration, the operating system and virtual machine, such as part of the structure above the standard. These elements form a complete J2ME real-time operating environment. Figure A shows how some of these combined. J2ME offers two configurations: Connected Limited Device Configuration (CLDC) and the Connected Device Configuration (CDC). This two configurations of equipment based on the memory footprint for different types of equipment.
Configuration designated smallest functional group and related Java Virtual Machine (JVM) should support the Java class libraries. Conceptually speaking, the configuration of the virtual machine (VM) running the top, such as when you use a CLDC and CDC configuration, you will relate to the VM relevant, because the two are closely linked.
However, it should be noted that in J2ME, is not affiliated with the allocation of a specific VM, he can work with other VM and support of the libraries. For example, the CLDC and applications can be designated basic function of the VM work together. On the details, see CLDC HotSpot Virtual Machine Application white pages.
To help you understand J2ME configuration layer role, I will CLDC and CDC were to elaborate.
CLDC
CLDC is for less than 512 KB memory footprint of the equipment configuration. CLDC is based KVM, it is highly optimized JVM, he addressed the 16-bit or 32-bit microprocessor, 160 to 512 KB of memory-based low-end, network connectivity, battery-powered equipment. Typical memory requirement is 128 KB make it to store KVM and related libraries. More information on the KVM from the Sun's KVM white pages to be.
On the network, CLDC targeted at the limited and intermittent wireless connectivity equipment, all J2ME CLDC software applications running on should be able at any other high-end running on the Java VM. Of course, this requires the support of the CLDC. CLDC configurations focus on I / O, networking, and security issues, international issues and the core Java libraries, and other related areas.
And event handling, user and application interaction, applications, content management, and other survival-related fields is to be dealt by the Profile. Use interface definition (for specific equipment, such as pagers, mobile phones and PDA) Profile is also within the scope of the layer, it built on the top, and use J2ME configuration. Mobile Information Device Profile (MIDP) is a J2ME profile, which defines the use of CLDC equipment of the user interface related norms.
CLDC J2SE access from the vast majority of the class, but some equipment aimed at the small memory footprint of the new category is not obtained from the J2SE APIs. J2SE done on the category of inheritance and CLDC new category-specific information, refer to a 1.0 CLDC 6.2 and 6.3 versions of the content. Java language specification in a number of floating-point support is no exception, no examples of the type of complete support and limited error handling capabilities.
Mentioned here CLDC HotSpot applications are also relevant, and it CLDC equivalent to the use of the equipment configuration in the Java VM KVM replacement. According to Sun, CLDC HotSpot VM is a high-performance implementation of the JVM (32 using CLDC v1.0 norms). He in the same memory footprint on the KVM operation than an order of magnitude higher than the better performance.
CDC: complete Java platform
CDC is applied to a larger memory, 2 MB or more particularly the equipment, CDC against limited and intermittent wireless connectivity equipment, CDC Foundation profile with the CVM and common definition of a complete J2ME environment.
CVM for users and embedded devices designed fully functional JVM, it supports all the Java 2 v1.3 VM security, JNI, JVMDI, RMI, cited weak functions and libraries. Essentially, CVM has a presence in all desktop systems with the function of the JVM.
CDC from the smallest of J2SE Java component data packets. Foundation profile from the user equipment needed to maintain the composition of the class library and APIs. So, if you work in a CDC J2ME-based environment, you need to update your code to make APIs replacement.
CDC is an extension of the CLDC therefore exists between the two configurations upward compatibility. CDC, and Foundation profile also provides real-time PersonalJava norms on the use of the application development process is fully compatible with.
Aggregate
J2ME model system so that different types of equipment "Special Edition" the creation of Java. As more and more equipment manufacturers have begun to accept the J2ME technology and the use of equipment J2ME increase, the updated J2ME profiles will be applied. Adopted for the development of Java-based device to provide a public platform for the smallest, J2ME configuration of the structure used to the way that these particular version of Java.
Source: www.jspcn.net
↑ Back J2me configuration problems
The letter a long time ago, to more like Notepad + wtk, huh!
Should first be downloaded from the following address related software.
J2SDK1.4.2_03 + WTK2.1: http://java.sun.com
Eclipse3.0RC2 http://www.eclipse.org
EclipseME0.4.1 http://sourceforge.net
Then follow the order of installation J2SDK1.4.2_03, WTK2.1, Eclipse3.0RC2 and EclipseME0.4.1, installed after j2sdk classpath environment variable should be set up, such as path and JAVA_HOME environment variables, I do not say more. I can make reference to the former article.
Settings can be HelloWorld.java write a test procedure for testing. At the command line type javac HelloWorld.java be class document input java Helloworld output Hello World on the screen so that j2SDK installed correctly.
Next WTK2.1 installation, and general applications like the installation. KToolBar after installation from the inside running to WTK2.1 inside onboard some Demo, if normal operations said WTK installed correctly.
Below we have to build the Eclipse development environment, Eclipse installation is very simple, you directly to Eclipse3.0RC2 to extract c: \ eclipse on it. Direct operating Eclipse.exe so you can see the Eclipse operation of the interface. If not used Eclipse so you can see the help document, the project itself to be a small operation to java.
Next, we want to install EclipseME.0.4.1 plug, and then extract EclipseME0.4.1 Eclipse closed to the c: \ eclipse \ plugin inside, restart Eclipse, select windows-> help-> software updates-> can find and instand J2ME development platform configuration.
In the dialog box that appears, select local installation, find the corresponding decompression position on it.
↑ Back Spring XML configuration of the 12 skills
↑ Back IIS configuration JSP environment Destination
Colombian 101 7.99 0 0
French_Roast 49 8.99 0 0
Espresso 150 9.99 0 0
Colombian_Decaf 101 8.99 0 0
French_Roast_Decaf 49 9.99 0 0
101 Acme, Inc. 99 Market Street Groundsville CA 95199
49 Superior Coffee 1 Party Place Mendocino CA 95460
150 The High Ground 100 Coffee Lane Meadows CA 93966
(COF_NAME VARCHAR (32),
SUP_ID INTEGER,
PRICE FLOAT,
SALES INTEGER,
TOTAL INTEGER)
FROM Employees
WHERE Last_Name LIKE Washington
Last_Name like Washington
(COF_NAME VARCHAR (32), SUP_ID INTEGER, PRICE FLOAT, +
SALES INTEGER, TOTAL INTEGER);
(COF_NAME VARCHAR (32), SUP_ID INTEGER, PRICE FLOAT, +
SALES INTEGER, TOTAL INTEGER));
Stmt.executeUpdate (
INSERT INTO COFFEES +
VALUES ( `Colombian`, 101, 7.99, 0, 0));
VALUES ( `French_Roast`, 49, 8.99, 0, 0));
VALUES ( “ Espresso, 150, 9.99, 0, 0));
Stmt.executeUpdate (INSERT INTO COFFEES +
VALUES ( `Colombian_Decaf`, 101, 8.99, 0, 0));
Stmt.executeUpdate (INSERT INTO COFFEES +
VALUES ( `French_Roast_Decaf`, 49, 9.99, 0, 0));
————— —— —– —– —–
Colombian 101 7.99 0 0
French_Roast 49 8.99 0 0
Espresso 150 9.99 0 0
Colombian_Decaf 101 8.99 0 0
French_Roast_Decaf 49 9.99 0 0
——– ———- —–
Colombian 7.99
French_Roast 8.99
Espresso 9.99
Colombian_Decaf 8.99
French_Roast_Decaf 9.99
SELECT COF_NAME, PRICE
FROM COFFEES
WHERE PRICE <9.00
——– ——- —–
Colombian 7.99
French_Roast 8.99
Colombian Decaf 8.99 Tomcat5 data source configuration mysql4
Softe version:
Jdk-1_5_0_01
Tomcat5.5.12
Mysql4.1.14
Mysql-connector-java-3.1.111-bin.jar
Mysql in the C: \ Program Files \ MySQL \ MySQL Server 4.1
Jdk in the C: \ jdk1.5.0_01
(
Id int (2),
Name varchar (6)
);
Insert into member values (2, "conan");
JNDI Name: MyPool / / connection pool name
Data Source URL: jdbc: mysql: / / localhost: 3306/mywebdb? AutoReconnect = true
JDBC Driver Class: com.mysql.jdbc.Driver
/ / Driver would be downloaded.
User Name: / / database user name.
Password: / / database password.
Max. Active Connections: / / link the largest number of activities, the Open-0.
Max. Idle Connections: / / wait for the greatest number of links, the Open-0.
Max. Wait for Connection: / / connect timeout ms, -1 for the infinite.
Type = "java.lang.Integer"
Value = "30" />
Description = "User database that can be updated and saved"
Name = "UserDatabase"
Type = "org.apache.catalina.UserDatabase"
Pathname = "conf / tomcat-users.xml"
Factory = "org.apache.catalina.users.MemoryUserDatabaseFactory" />
Type = "javax.sql.DataSource"
DriverClassName = "com.mysql.jdbc.Driver"
Password = "admin"
MaxIdle = "5"
MaxWait = "5000"
Username = "root"
Url = "jdbc: mysql: / / localhost: 3306/mywebdb? AutoReconnect = true"
MaxActive = "5" />
RedirectPort = "8443"
MinSpareThreads = "25"
ConnectionTimeout = "20000"
MaxSpareThreads = "75"
MaxThreads = "150"
MaxHttpHeaderSize = "8192">
RedirectPort = "8443"
ConnectionTimeout = "0"
Protocol = "AJP/1.3">
Name = "Catalina">
Name = "localhost">
<% @ Page import = "java.io. *, java.util .*, java.sql .*, javax.sql .*, javax.naming .*"%>
<% @ Page contentType = "text / html; charset = GB2312"%>
<head> </ Head>
<body>
<%
Try (
Statement stmt;
ResultSet rs;
Javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ( "java: comp / env / MyPool"); / / red for the connection pool of characters, other fixed.
Java.sql.Connection con = ds.getConnection ();
Rs = stmt.executeQuery ( "select * from tested");
While (rs.next ()) (
Out.print (rs.getString (2));
)
Rs.close ();
Stmt.close ();
Con.close ();
) Catch (Exception e) (
Out.print (e.getMessage ());
)
%>
</ Body>
↑ Back
Timing configuration running Servlet
Abstract: Timing configuration running Servlet
<tr> <td> Amend Web.xml settings run every 15 minutes Servlet
Set daily operation of 16:30 and 20:00 Servlet
</ Td> </ tr> </ table>
↑ Back