Code and steps for JDBC Connection database in Java development
Create a JDBC Connection database program, a total of 7 steps:1. Load Database driverBefore connecting to the database, you first load the drive to the JVM for the database you want to connect to, which is implemented by the static method forname (
, applications often need to access multiple different databases. How to access different databases through the same connection pool is a core issue that the application needs to address. Here's a way to fix this:First, a class that defines a database connection pool parameter, defines the database's JDBC driver class name, the URL of the
results
4) execute the SQL command and process the returned results
5) after processing, if a returned result set exists, disable the ResultSet object.
6) Close the corresponding Statement object
7) Close the Connection object
3. Case study 1
// 1. The loaded Driver com. mysql. jdbc. Driver is the path of the Driver Class. forName ("com. mysql. jdbc. Driver ")
the database and return results
4) execute the SQL command and process the returned results
5) after processing, if a returned result set exists, disable the ResultSet object.
6) Close the corresponding Statement object
7) Close the Connection object
3. Case study 1
// 1. Load the driver com. mysql. jdbc. driver is the path of the Driver Class. forName ("com. mysql. jd
object Resource Manager of SQL Server Management Studio, right-click the Server and choose Properties> Security> Server Authentication.
Select "SQL Server and Windows Authentication Mode"-> OK-> OK.
3. Disable the firewall.
Note:
Note the differences between 2000 and 2005 when writing the connection code:
Connect to SqlServer2000Copy codeThe Code is as follows:Class. forName ("com. microsoft. jdbc. sqlserv
Tags: creat jdbc mysql Execute SQL data database blog system administration send"What is it?" JDBC Full name javadatabaseconnectivity, a Java database connection, is a Java API that executes SQL statements. Programmers can connect to a relational database through JDBCAPI and use Structured query statements (that is, SQL) to complete queries and updates to the dat
Document directory
Required Preparations
Connected theoretical knowledge
Connection test
Perform SQL operations in Java
Required Preparations 1. Install MySQL. For more information, see http://blog.csdn.net/jueblog/article/details/9499245 、to download the JDBC driver. You can download from the official website, or click the http://download.csdn.net/detail/oyuntaolianwu/5822697 to download 3, in eclips
a database, set up a table in the library, a list of several fields (remember to give an ID field, unique primary key, self-added sequence), and then casually give two data will be good, used to test the function, as shown:
The second step is to get through the database (this example would like everyone to knock on their own, not much time, familiar with how JDBC and the database to deal with, so the diagram), as shown:
The third step, the tran
The procedure can be divided into the following steps:
1. Create a databaseCreate users, username, and password in the database work.2. Create a New java project in MyEclipse and name it jdbcexample3. Add the connection class package (mysql-connector-java-5.1.6-bin.jar) required to connect to MySQL-> this package is the top priority, should not be omitted.4. Create an implementation class in the project:JDBCExample01.javaCode
Code highlighting produc
The JDBC driver of Informix is type 4.
1. Environment DescriptionOS: Windows XPInformix: IDS V10.00.TC1JDBC: Informix JDBC Embedded SQLJ V2.20JC22. JDBC ConfigurationAfter Informix JDBC is installed, add the ifxjdbc. jar path to the CLASSPATH environment variable, for example, CLASSPATH = C: \ ifxjava_home \ lib \ ifxj
class mysqltest {public static void main (string [] ARGs) {connection conn = NULL; try {// load the MySQL Driver Class. forname ("com. mySQL. JDBC. driver "); // connect to MySQL on localhost and specify to use the test database. The username is root and the password is *** conn = drivermanager. getconnection ("JDBC:
This article mainly introduces the process of JDBC connecting to Informix IDs, mainly including environment description, JDBC Configuration and demo code.
1. Environmental description
OS: Windows XP Informix: IDS V10.00.TC1 JDBC: Informix JDBC Embedded SQLJ V2.20JC2
2.JDBC
box appears, enter the name of the data source in the data source name "Jdbc-odbc", click the Select button, select the database to operate "Student.mdb", click OK button to complete the configuration of the data source. As shown in the figure:
4, the data source configuration is good, you can write to get the connection code, as follows:
Copy Code code as follows:
Class.forName ("Sun.j
, when I was working on a project, I needed to access data from other databases. I could only use the ODBC driver on the Windows platform. The cost of doing so is that you can only deploy applications on the Windows platform, rather than using Unix-like systems. This is like being shackled. My requirement is to be cross-platform, so there is only one option-JDBC.
This is not surprising. In today's enterprise applications, only
Common Methods for connecting to a database through JDBC are summarized as follows:
I. DB2
Class. forname ("com.ibm.db2.jdbc.net. db2driver ");
String url = "JDBC: DB2: // dburl: Port/dbname"
CN = drivermanager. getconnection (URL, username, password );
2. Microsoft sqlserver (Microsoft)
Class. forname ("com. Microsoft.
Java uses JDBC Connection database to do JSON encapsulation and parsing examples
This example is an example of using SOLServer2007 to connect a database with JDBC and to query the data format encapsulated into JSON.
Directly on the code--
Main function
Package Com.kuatang.jsondatas;
Import Java.io.File;
Import java.util.ArrayList;
Import Java.util.HashMap
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.