following insert @Override public
void Insert (Student Student) {
jdbctemplate.update ("INSERT INTO Student VALUES ('" + Student.getid ()
+ "', '" + student.getname () + "', '" + student.getage ()
+ "', '" + student.getsex () + "')");
}iii. Examples of useHere we will instance spring JDBC and MySQL database connection, build table, perform insert, find, delete and other functions.1, a new Javap
encapsulate frequently used JDBC database connections into a class that can be invoked directly when used.
disadvantages such as the following:
The speed of access to data records has been affected to a certain extent;
Changing the data source is difficult: JDBC supports multiple databases, and the operations between the various databases are different, which can cause a lot of trouble fo
encapsulate frequently used JDBC database connections into a class that can be invoked directly when used.
disadvantages such as the following:
The speed of access to data records has been affected to a certain extent;
Changing the data source is difficult: JDBC supports multiple databases, and the operations between the various databases are different, which can cause a lot of trouble fo
Different databases correspond to different drivers, to access the MySQL database using jdbc api, You need to import the MySQL database driver package mysql-connector-java-5.1.7-bin under the libs directory of the project.
Different database manufacturers have different driver classes, specifically:
Oracle10g: Or
with ODBC;
Object-oriented: the ability to encapsulate frequently used JDBC database connections into a class that can be invoked directly when used.
disadvantages such as the following:
The speed of access to data records has been affected to a certain extent;
Changing the data source is difficult: JDBC supports multiple databases, and the operations between the various databases are
procedure and provide parameters (if the stored procedure has parameters; in general, SQL statements need to transmit the executed statement string to the database server, which is longer than the stored procedure to the database server;3) high security. Assigning values to Stored Procedure parameters can only be passed through question marks (this can be reflected through the following JDBC call example f
affected to a certain extent;
It is difficult to change the data source: JDBC supports multiple databases, and operations between different databases must be different, which makes it very difficult to change the data source.
2. process and principle of connecting to the database through JDBC
1,Load the driver of the specified database in the development environment. For
1. Preface
Database applications are often used in many software systems and are indispensable for developing large systems. However, if the database resources are not well managed (for example, resources such as the database cursors (resultset), statement, and connection) are not recovered in time), system stability is often directly caused. This type of instability is not only caused by the database or the system itself. It will be gradually reveal
following figure.
Now we are using java to operate mysql databases.
JDBC operation Example 1: The simplest query operationImport java. SQL .*;
Public class Demo {// Throws all exceptions for the moment to compact the codePublic static void main (String [] args) throws Exception {// Register the database driverClass. forName ("com.
Mysql 12: The DriverManager method for connecting to the database through JDBC
Connect to the database through JDBC
Create a program to connect to the database using JDBC, which contains seven steps:
1. load the JDBC driver:
Before connecting to the database, load the d
MySQL installation, configuration, use, and JDBC link bitsCN.com
Download:
URL: http://dev.mysql.com/downloads/mysql/5.5.html#downloads
Select No thanks, juststart my download.
Mysql-5.5.36-win32. Msi 33.7 M
Mysql-5.5.36-winx64. Msi 35.3 M
Navicat V8.2.12ForMySQLUsage:
1. Cl
1. When JDBC is connected to each database, there are many identical code parts. Write these parts separately in a class, connect to a specific database based on input parameters such as driver, URL, user, and password. The tool class code is as follows:
Package mine. util. database; import Java. SQL. connection; import Java. SQL. drivermanager; import Java. SQL. sqlexception; import Java. SQL. statement;/*** this tool class is used for database conne
encapsulate frequently used JDBC database connections into a class that can be invoked directly when used.
disadvantages such as the following:
The speed of access to data records has been affected to a certain extent;
Changing the data source is difficult: JDBC supports multiple databases, and the operations between the various databases are different, which can cause a lot of trouble fo
encapsulate frequently used JDBC database connections into a class that can be invoked directly when used.
disadvantages such as the following:
The speed of access to data records has been affected to a certain extent;
Changing the data source is difficult: JDBC supports multiple databases, and the operations between the various databases are different, which can cause a lot of trouble fo
encapsulate frequently used JDBC database connections into a class that can be invoked directly when used.
disadvantages such as the following:
The speed of access to data records has been affected to a certain extent;
Changing the data source is difficult: JDBC supports multiple databases, and the operations between the various databases are different, which can cause a lot of trouble fo
encapsulate frequently used JDBC database connections into a class that can be invoked directly when used.
disadvantages such as the following:
The speed of access to data records has been affected to a certain extent;
Changing the data source is difficult: JDBC supports multiple databases, and the operations between the various databases are different, which can cause a lot of trouble fo
function with ODBC;
Object-oriented: the ability to encapsulate frequently used JDBC database connections into a class that can be invoked directly when used.
disadvantages such as the following:
The speed of access to data records has been affected to a certain extent;
Changing the data source is difficult: JDBC supports multiple databases, and the operations between the various data
in this tutorial, we'll extend last Maven + Spring Hello World example by adding JDBC support, to use Spring + JDBC To insert a record into a customer table.1. Customer tableIn this example, we is using MySQL database.CREATE TABLE ' customer ' ( ' cust_id ' INT (TEN) UNSIGN
JDK + JDBC + MySQL instance and precautions by qx. zhong
Hangzhou 29jun 2014
Development Environment
OS: Win8.1 x64
JDK: 1.8 SE
DB: MySQL 5.5
Lib: mysql-connector-java.jar
1. Special Correspondence between MySQL database data types and JDK
The following table lists only a
it, and print the result:
Class clcs = UserInfo.class;
Method f = clcs. getDeclaredMethod ("setUsername", String. class); the type of input parameters in the original function. class. for example, if the original setXXX parameter needs to be input, the String is written during reflection. class.
6. JavaBean is a type of reflection. reflection has no requirements on constructor and so on. JavaBean requires that this class must inherit Serializab
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.