JDBC Connection database, jdbc database
JDBC connection to the database is generally divided into three steps:
(1) register the database driver
(2) create a database connection URL
(3) obtain the Connection object
The Code is as follows:
1 try {2 // load the database driver and register it with the driver Manager 3 Class. forName ("com. mysql.
Basic Database Operation statements, JDBC programming steps, and jdbc programming steps
We don't know where to start when we get started with data, but in fact we only need to know a few basic operation statements, below I will briefly introduce the basic database operation statements and JDBC programming steps:
Connection command: mysql-h [host address]-u [user
JDBC (database connection and use), jdbc database
1. Introduction to JDBC
Quick StartPreparations:Ii. encoding stage:
Database connection process detailsIn development, the reflection method is generally used to register the driver. There are two advantages: 1. the driver is registered only once, improving efficiency. 2. You can extract the driver's full-outsourc
Tags: style blog color io os using Java AR forStart Thriftjdbcserver:CD $SPARK _home/sbinstart-thriftserver. SH To access the Thriftjdbcserver code snippet using JDBC: PackageCom.luogankun.spark.sqlImportJava.sql.DriverManagerImportjava.sql.ConnectionImportjava.sql.PreparedStatement/*** JDBC Code access thrift JDBC Server *@authorLuogankun*/Object Jdbcthriftserve
Detailed explanation of the encapsulation of JDBC database links and related methods, detailed explanation of jdbc database Encapsulation
Details about the encapsulation of JDBC database links and related methods
The MySQL database is used. First, import the driver class and obtain the data link based on the database URL and user name and password. Because the My
Basic jdbc (I) simple use of MySQL and basic jdbc mysql
JDBC can be used to establish a connection with the database, send statements for database operations, and process the results.
The first thing the program needs to do is to load the database driver. Here I am using mysql:
1 String driverName=new String("com.mysql.jdbc.Driver");2 Class.forName(driverName);
I used jdbc to connect to the database before writing the program. Suddenly I learned how to connect to the database using odbc. I found that there is a difference between the two.JDBCClass. forName ("database driver name"); // such as com. microsoft. jdbc. sqlserver. string url = "jdbc: microsoft: sqlserver: // localhost: 1433; DatabaseName = database name"; jav
Improves the performance of JDBC batch operations and jdbc PerformanceJDBC
When you use the insert into... VALUES () statement to INSERT data in batches, you should use the JDBC PreparedStatement batch operation method instead of using one execution method.
For example (Source: http://superjavason.iteye.com/blog/255423 ):
For example, the Code has three key
1. Business
All update operations performed by a session either succeed together or fail together
For example:A to B transfer, transfer this process if there is a problem, the transaction can let the data back to the original "a account of the money has not changed, B account of the money has not changed." Case Description: /* * we To simulate the scenario of A to B account transfer * A and B accounts have 1000 dollars, now I let a account to B account 500 dollars *
1. Download the debug version number jar PackageThe first step is to download the JDBC Jar package for the debug version number, with the name of the jar package for the debug version number Jdbcx_g.jar (for example, as seen). The jar package for the debug version number, such as oracle11g, is Jdbc6_g.jar.Click here to download: http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-09076
1. Database--Create a data table1 Create Table clob_test2(3integernotnullPrimary key,4textnotnull5 );2. Working with JDBC for large pieces of text data(1) Writing text data to the database1 @Test2 Public voidCreate ()throwsSQLException, IOException {3Connection conn =NULL;4PreparedStatement PS =NULL;5ResultSet rs =NULL;6 Try {7 //Establish a connection8conn =jdbcutils.getconnection ();9String sql = "INSERT into Clob_test (B
JDBC uses database transactions and jdbc database transactions
How does a java program use jdbc to define a transaction?
Set connection to not automatically submitChange to manual submission;Write the operation database in trycatch.Throw an exceptionConnection rollback;This is a practice.Private Connection conn = null;Try {Conn. setAutoCommit (false )
stored procedures: A set of SQL statements that are compiled to complete a particular function, stored in a database, and executed by specifying the name of the stored procedure and giving parameters. Stored procedures can contain logical control statements and data manipulation statements, which can accept parameters, output parameters, return single or multiple result sets, and return values.Because stored procedures are compiled on the database server and stored in the database when they are
before manipulating Data1) Log in to the database server (mysql-u root-p password) via MySQL client tool2) Writing SQL statements3) Send SQL statement to database server execution What is jdbc? the technique of sending SQL statements using Java Code (Programs) is jdbc technology!!!! using jdbc to send sql Prerequisites
Log on to the database server (c
Jdbc Core Technology 3-stored procedure and jdbc Core TechnologyWhat is a stored procedure? A stored PROCEDURE is a piece of code stored IN a database. It can be called by a program to create a stored PROCEDURE create PROCEDURE SELECT_TESTTWO (in testid long, inout testall varchar (255 ))BEGINSELECT 'name' from test where id = testid into testall;ENDCreate a stored PROCEDURE command: create PROCEDURE PROCED
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.