Log Title: Several Issues of Operating Database
Posted: 2005-9-6 15:59:00
First, when you record it in the database, don't get used to SELECT * from .... This is very resource, and all records are selected each time.
Second, when processing in JSP, you need to take the database, a part of the record, part of the record, SQL statement can be written:
[Code] int startnum = (target_page - 1) * page_size; // target_page need to get the page number String sql = "select top" page_size "* from InsureProductType where (TypeID not in (select top" startnum "TypeID from InsureProductType) "; [Code]
Mean: Take the beginning of the beginning (not in the former STARTNUM record) Page_Size strip record. A SQL statement, clear and clear.
Third, the different versions of SQL Server in MSSQL should correspond to different patches, otherwise it will cause local area network (once happened). The specific patch of each version is determined: SQL statement "select @@ version;" get the version number, version number corresponds to the version:
8.00.194 ------- SQL Server 2000 RTM (Is the SP4 patch?) 8.00.384 ------- (SP1) 8.00.534 ------- (SP2) 8.00.760 ------- (SP3)
4. To build a database connection must be entered into DriverManager by passing the URL, DRIVER, USER, Password, etc., the drivers and URLs of various databases are different, and the common JDBC connection URL is as follows:
MSSQL:
Driver: "com.microsoft.jdbc.sqlserver.sqlserdriver"
URL: "JDBC: Microsoft: SQLServer: // localhost: 1433; selectMethod = Cursor;" (Need to note that the parameters in mysql are separated by "/", and ";" in MSSQL is separated, and the other selectMethod = Cursor is used to support If you don't add this, if you don't add this, you will report an error when making a manual submission.
MySQL:
Driver: "org.gjt.mm.mysql.driver"
URL: "JDBC: MySQL: // Localhost: 3306 / DatabaseName"
ODBC Class.Forname ("Sun.jdbc.odbc.jdbcodbcodbdriver"); Connection CN = DriverManager.getConnection ("JDBC: ODBC:" SDSN, SUSR, SPWD); (where SDSN is a data source name)
PostgreSQL (http://www.de.postgresql.org/) pgjdbc2.jar Class.forName ( "org.postgresql.Driver"); cn = DriverManager.getConnection ( "jdbc: postgresql: // MyDbComputerNameOrIP / myDatabaseName", sUsr , SPWD); Oracle (http://www.racle/oracle9i/) Classes12.zip class.Forname ("Oracle.jdbc.driver.Oracledriver); cn = drivermanager.getConnection (" JDBC: Oracle: Thin: @mydbcomputernameorip: 1521: Orcl ", SUSR, SPWD);
Sybase (http://jtds.s.sourceforge.net/) jconn2.jar class.Forname ("com.sybase.jdbc2.jdbc.sybdriver"); cn = drivermanager.getConnection ("JDBC: Sybase: TDS: mydbcomputernameorip: 2638" , SUSR, SPWD); // (Default-username / password: "dba" / "sql")
Among them, the database type black body means I have not used it. I didn't listed, I used it, 嘻嘻