Java Connection Database driver code integrated sharing __ about databases

Source: Internet
Author: User
Tags db2 informix postgresql stmt sybase sybase database
1, oracle8/8i/9i database (thin mode)
Class.forName ("Oracle.jdbc.driver.OracleDriver"). newinstance ();
String url= "Jdbc:oracle:thin: @localhost: 1521:ORCL";
ORCL is the SID of the database
String user= "Test";
String password= "Test";
Connection conn= drivermanager.getconnection (Url,user,password);


2. DB2 Database
Class.forName ("Com.ibm.db2.jdbc.app.DB2Driver"). newinstance ();
String url= "Jdbc:db2://localhost:5000/sample";
Sample for your database name
String user= "admin";
String password= "";
Connection conn= drivermanager.getconnection (Url,user,password);


3. SQL server7.0/2000 Database
Class.forName ("Com.microsoft.jdbc.sqlserver.SQLServerDriver"). newinstance ();
String url= "Jdbc:microsoft:sqlserver://localhost:1433;databasename=mydb";
MyDB as a database
String user= "SA";
String password= "";
Connection conn= drivermanager.getconnection (Url,user,password);


4. Sybase database
Class.forName ("Com.sybase.jdbc.SybDriver"). newinstance ();
String url = "Jdbc:sybase:tds:localhost:5007/mydb";
MyDB for your database name
Properties sysprops = System.getproperties ();
Sysprops.put ("User", "userid");
Sysprops.put ("Password", "User_password");
Connection conn= drivermanager.getconnection (URL, sysprops);


5. Informix Database
Class.forName ("Com.informix.jdbc.IfxDriver"). newinstance ();
String URL =
"Jdbc:informix-sqli://123.45.67.89:1533/mydb:informixserver=myserver;
User=testuser;password=testpassword ";
MyDB for Database name
Connection conn= drivermanager.getconnection (URL);


6. mysql Database
Class.forName ("Org.gjt.mm.mysql.Driver"). newinstance ();
String url = "jdbc:mysql://localhost/mydb?user=soft&password=soft1234&useunicode=true& Characterencoding=8859_1 "
MyDB for Database name
Connection conn= drivermanager.getconnection (URL);


7. PostgreSQL Database
Class.forName ("Org.postgresql.Driver"). newinstance ();
String url = "Jdbc:postgresql://localhost/mydb"
MyDB for Database name
String user= "MyUser";
String password= "MyPassword";
Connection conn= drivermanager.getconnection (Url,user,password);

8, Jdbc-odbc Bridge
Class.forName ("Sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=drivermanager.getconnection ("jdbc:odbc:jsp");
JSP for the established ODBC data source name, first to set the SQL Server table as the data source. Added with system DNS in Administrative Tools-Data source ODBC.






8.oracle8/8i/9i database (thin mode)
Import java.sql.*;
Class.forName ("Oracle.jdbc.driver.OracleDriver"). newinstance ();
String url= "Jdbc:oracle:thin: @localhost: 1521:ORCL"; ORCL is the SID of the database
String user= "Test";
String password= "Test";
Connection conn= drivermanager.getconnection (Url,user,password);
Statement stmtnew=conn.createstatement ();


9.DB2 Database
Import java.sql.*;
Class.forName ("Com.ibm.db2.jdbc.app.DB2Driver"). newinstance ();
String url= "Jdbc:db2://localhost:5000/sample"; Sample for your database name
String user= "admin";
String password= "";
Connection conn= drivermanager.getconnection (Url,user,password);
Statement stmtnew=conn.createstatement ();
ResultSet rs = Stmt.executqurey (SQL); /


10.SQL server7.0/2000 Database
Import java.sql.*;
Class.forName ("Com.microsoft.sqlserver.jdbc.SQLServerDriver"). newinstance ();
String url= "JDBC:MICROSOFT:SQLSERVER://LOCALHOST:1433;DATABASENAME=DB2"; 7.0, 2000
String url= "JDBC:SQLSERVER://LOCALHOST:1433;DATABASENAME=DB2"; 2005
DB2 for Database name
String user= "SA";
String password= "";
Connection conn= drivermanager.getconnection (Url,user,password);
Statement stmtnew=conn.createstatement ();
ResultSet rs = Stmt.executqurey (SQL); /


11.Sybase Database
Import java.sql.*;
Class.forName ("Com.sybase.jdbc.SybDriver"). newinstance ();
String url = "Jdbc:sybase:tds:localhost:5007/mydb";//mydb for your database name
Properties sysprops = System.getproperties ();
Sysprops.put ("User", "userid");
Sysprops.put ("Password", "User_password");
Connection conn= drivermanager.getconnection (URL, sysprops);
Statement stmtnew=conn.createstatement ();
ResultSet rs = Stmt.executqurey (SQL); /


12.Informix Database
Import java.sql.*;
Class.forName ("Com.informix.jdbc.IfxDriver"). newinstance ();
String url = "Jdbc:informix-sqli://123.45.67.89:1533/mydb:informixserver=myserver;
User=testuser;password=testpassword "; MyDB for Database name
Connection conn= drivermanager.getconnection (URL);
Statement stmtnew=conn.createstatement ();
ResultSet rs = Stmt.executqurey (SQL); /


13.MySQL Database
Import java.sql.*;
Class.forName ("Org.gjt.mm.mysql.Driver"). newinstance ();
Class.forName ("Com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost/mydb?user=soft&password=soft1234&useunicode=true& Characterencoding=8859_1 ";
String url = "Jdbc:mysql://localhost:3306/mydb";


MyDB for Database name
Connection conn= drivermanager.getconnection (URL, "root", "root");
Statement stmtnew=conn.createstatement ();


14.PostgreSQL Database
Import java.sql.*;
Class.forName ("Org.postgresql.Driver"). newinstance ();
String url = "Jdbc:postgresql://localhost/mydb"//mydb for database name
String user= "MyUser";
String password= "MyPassword";
Connection conn= drivermanager.getconnection (Url,user,password);
Statement stmtnew=conn.createstatement ();


15.access Database Direct with ODBC
Import java.sql.*;
Class.forName ("Sun.jdbc.odbc.JdbcOdbcDriver");
String url= "Jdbc:odbc:driver={microsoft Access Driver (*.mdb)};D bq=" +application.getrealpath ("/data/reportdemo.mdb ");
Connection conn = drivermanager.getconnection (URL, "sa", "");
Statement stmtnew=conn.createstatement ();


16. Program Timing
Long Time1=system.currenttimemillis ();
Long Time2=system.currenttimemillis ();
Long interval=time2-time1;


17. Delay
try {
Thread.Sleep (Integer.parse (%%1));
catch (Interruptedexception e) {
E.printstacktrace ();
}


18. Connect Excel Files
Import java.sql.*;
Class.forName ("Sun.jdbc.odbc.JdbcOdbcDriver");
String url = "Jdbc:odbc:driver={microsoft Excel driver (*.xls)};D Bq=d:\\mydb.xls";//Do not set data source
String user= "MyUser";
String password= "MyPassword";
Connection conn= drivermanager.getconnection (Url,user,password);
Statement stmtnew=conn.createstatement ();


Process


The first step: demand Research and analysis
1 related systems analysts and users to understand the requirements, and then use Word list of the system to develop a large function module, each large function module has a small function module, for some of the requirements are more clearly related to the interface, in this step can be a preliminary definition of a small number of interfaces.
2 System analyst in-depth understanding and analysis of requirements, according to their own experience and needs in Word or related tools to make a document system functional requirements document. This time the document will be clear example with the system of large functional modules, large functional modules have small function modules, and also examples of related interface and interface functions.
3 System analyst and user reconfirm demand again.
Step Two: Outline design
First of all, developers need to design a software system, that is, system design. The outline design needs to consider the design of the software system, including the basic processing flow of the system, the organization structure of the system, the module partition, the function allocation, the interface design, the operation design, the data structure design and the error handling design, which provide the foundation for the detailed design of the software.
Step Three: Detailed design
On the basis of the outline design, the developer needs to carry on the detailed design of the software system. In the detailed design, it describes the main algorithm, data structure, class hierarchy and call relation, which need to explain the design consideration of each program (each module or subroutine) in each level of the software system, so as to encode and test. The requirements of the software should be guaranteed to be fully distributed to the entire software. The detailed design should be detailed enough to encode according to the detailed design report.
Fourth Step: Coding
In the software coding phase, according to the design requirements of data structure, algorithm analysis and module realization in the detailed design report of software system, the developer starts to write program work separately, realizes the function of each module, and realizes the requirement of function, performance, interface and interface of the target system.
Step Fifth: Test
Test the system that is well written. Given to the user, the user uses the following one to confirm each function.
Sixth step: Software Delivery preparation
After the software test proves that the software has reached the requirement, the software developer should submit the product of the target installation program, database data dictionary, user installation Manual, user Guide, requirement report, Design report and test report to the user.   The user installation manual should describe in detail the requirements of the installation software for the operating environment, the definition and content of the installation software, the specific installation steps of the client, server and middleware, and the system configuration after installation. "User Guide" should include the software functions of the use of the process, operating procedures, the corresponding business introduction, special tips and precautions, and other aspects of the content, when necessary, should also provide examples.
Seventh Step: Acceptance
User acceptance.

Mode
Rapid Prototyping Model: (need to quickly build a software prototype that can be run to understand and clarify problems)
The rapid prototyping model allows for a preliminary, incomplete analysis and definition of software requirements during the requirements analysis phase. Rapid design and development of software system prototype (show the software to be developed in all or part of the function and performance (process: the user of the prototype test and evaluation, give specific improvements to the views and rich refinement of software requirements, Modified by the developer)
Advantages: Overcome the drawbacks of the waterfall model, reduce the development risk due to unclear software requirements: A, the development technology and tools are not necessarily in line with mainstream development B, rapidly established systems plus continuous modifications may result in product quality under

Incremental model: (The linear sequence that is staggered by the progress of the schedule, each linear Xu Lei produces a scalable "increment" of the software, and the first increment is often the core product)
In common with other models: it is essentially iterative, like the prototype implementation model and other evolutionary methods
differs from the prototype implementation model: it emphasizes that each increment releases an operable product (it does not need to wait until all requirements are available, and can be developed as long as it touches the incremental package of requirements).
Advantages: 1. Flexible staff distribution, there's no need to put in a lot of human resources at first. 2, when the staff can not be completed within a limited time to complete the product, it can provide a way to launch the core products, can be released part of the function to the user (to the user sedation) 3, incremental can have planned management technology risk
Disadvantages: 1, if there is an intersection between the incremental package and not well handled, you must do a comprehensive system analysis
Note: This model is more suitable for the software development process that needs to be changed after the function is refined and developed separately.
Prototype Model: (sample model, using step-by-step refinement method to perfect the prototype)
Main idea: First borrow the existing system as a prototype model, through the "sample" continuous improvement, so that the final product is the user needs. The prototype model obtains the user's feedback by providing the user with the prototype, so that the developed software can truly reflect the user's demand,
Adopting the method: The prototype model uses the Step-by-step refinement method to perfect the prototype, which enables the prototype to be "fast" developed, avoiding the difficulty of responding quickly to the user's feedback in the lengthy development process like the waterfall model.
Advantages:
(1) Developers and users agree on "prototypes". In this way, it can reduce the errors in design and risk in development, but also reduce the time for user training, and improve the system's practicality, correctness and user satisfaction.
(2) Shorten the development cycle and speed up the project progress.  (3) Reduce costs.  Disadvantages: 1, when the production of the product, it is difficult to allow users to receive, to continue to carry out the project to bring unfavorable factors. 2. It is not advisable to use the prototype system as the final product. Using a prototype model development system, users and developers must agree:
Fountain Model: (with user demand as the driving force, object-driven model, mainly used in software development projects using object technology)
It is considered that the stages of the bottom-up cycle of the software development process are iterative and non gap-free characteristics of each other: the touch parts of the software are often repeated many times, with the associated object adding a progressive software component without gaps in each iteration: it has no obvious boundaries between activities (e.g., between analysis and design activities < Due to the application of object concepts, expression analysis, design, implementation and other activities only with object classes and Relationships >)
Advantages: 1, can improve the software project development efficiency, save development time, adapt to the object-oriented software development process
Inconvenience: 1, because the fountain model in each development phase is overlapping, so in the development process requires a large number of developers, it is not conducive to project management. 2, this model requires strict management of documents, making the audit difficult to increase, especially in the face of the possibility of adding a variety of information, needs and information at any time
Helical models: (suitable for projects with frequent changes in requirements < suitable for large and complex systems >)
It is mainly risk analysis and evaluation, a number of iterations along the helix, the process: 1, make a plan: Determine the software objectives, select the implementation plan, clarify the project development constraints 2, risk analysis: Analysis and evaluation of selected scenarios, consider how to identify and eliminate risk 3, implementation of the project: implementation of software development and validation; 4. Customer Evaluation: Evaluate the development work, propose corrective suggestions and make the next plan.
Advantages: 1, it is driven by risk, emphasizing alternatives and constraints to support software reuse, and helping to integrate software quality as a special goal in product development: 1, it is difficult to convince users that the results of this fireworks method can be controlled 2, the construction cycle is long (and software technology development is relatively fast, So often there will be after the software development, and the current level of technology has a big gap, can not meet the needs of the current user 3, unless the software developers are good at looking for possible risks, accurate analysis of risk, otherwise it will bring greater risk
Waterfall Model: (in essence, waterfall model is a software development architecture, repeated application (core idea: According to the process will be the problem of simplification, the realization of the function and design separate, convenient division of cooperation, the use of structured analysis and design methods to the logical implementation and physical implementation, according to the software life cycle from top to bottom, The order of the interconnected < like waterfall streams falling down >)
Disadvantages: 1, there is very little feedback between the various stages of the project, the partitions are completely fixed at each stage, generating a large number of documents between phases, increasing the workload by 2, and the user can only see the results later in the project lifecycle, increasing the risk of development by 3, requiring too many mandatory finish dates and milestones to track the stages of each project 4, Circular feedback is generated at each stage (if any information is not overwritten or the problem is found, it must be returned to the previous stage < even earlier activity > and make appropriate modifications, only if the previous phase is confirmed before the next stage) 5, Early errors may have to wait until later in the development phase of the test to be discovered, leading to serious consequences.
Advantages: 1, for the project to provide a phased checkpoint 2, when the completion of a phase, only need to focus on follow-up Phase 3, can be used in the iterative model of the waterfall model
According to the Waterfall Model phase division, software testing can be divided into unit testing, integration testing, System testing

Contact Us

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

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

A Free Trial That Lets You Build Big!

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

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

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