The following article describes the actual operation process of connecting JDBC to the MySQL database and the actual application code in the middle of the actual operation. The following describes the specific solution for connecting JDBC to the MySQL database, I hope this will help you in your future studies.
pub
voidRead () {Connection conn=NULL; PreparedStatement St=NULL; ResultSet RS=NULL; Try{conn=jdbcutils.getconnection (); String SQL= "Select Resume from Testclob where id=3"; St=conn.preparestatement (SQL); RS=St.executequery (); String Contentstr=""; String content= ""; if(Rs.next ()) {//Use resultset.getstring ("field name") to get the contents of large text dataContent = rs.getstring ("Resume"); //Use Resultset.getcharacterstream ("field name") to get the contents of large text dataReader reade
Use Hibernate to connect to the database of mysql5. Since the table uses a datetime time period, the following
Java. SQL. SQLException: Cannot convert value '2017-00-00 00:00:00 'from column 9 to TIMESTAMP.At com. mysql. jdbc. ResultSet. getTimestampFromBytes (ResultSet. java: 6864)At com. mysql. jdbc. ResultSet. getTi
Label:scenario : Traverse and process all the data in a large table, the data in this table may be thousands or hundreds of billions of dollars, many people may say with paging limit ... However, the requirement itself is more convenient for one-time traversal, and ORACLE/DB2 has a convenient cursor mechanism.For DB, the stream is actually what we call the cursor, and there are 2 ways to stream MySQL, the Client Side cursor and the server Side cursor.
! [1](img.ask.csdn.netupload201508211108161697_24384.png )! Warning) Navicat and JDBC are both normal (Windows). run cmd (Code page utf8) to mysql. the query result is on the left of the first figure. directly go to mysql (Code page simplified Chinese GBK) the right side of the first image. Command to view the second figure of
user, String password );
Note: Obtain the database connection according to the url. the user is the username used to log on to the database, and the password is the login password.
Database url Description: The url is written as: localhost can be replaced by the return address 127.0.0.1 pointing to the Local Machine
Common Database url:
Oracle -- jdbc: oracle: thin: @ localhost: 1521: sid
SqlServer -- jdbc
Get to know the common interface of JDBC in the first1. Driver Interface DriverThe driver for each database should provide a class that implements the Java.sql.Driver interface, referred to as the driver class. Typically, the driver class to connect to the database is loaded through the static method forname (String className) of the Java.lang.Class class, and the parameter is the full package name of the driver class to be loaded.For
Programs that generally get database connectionsClass.forName ("Com.mysql.jdbc.Driver"), final Connection Connection = (Connection) drivermanager.getconnection ("jdbc : Mysql://localhost:3306/testdb "," guoxiaoming "," guoxiaoming ");-----------------------------Register MySQL driver class next time, we are now focusing on the establishment of connection---------
How to quickly insert data in batches using JDBC in a MySQL database, jdbcmysql
How can we improve efficiency when we use JDBC to connect to the MySQL database for data insertion, especially continuous insertion of large batches of data (more than 10 million?
In the JDBC pro
The test code for the newly created java project is as follows. The driver has been copied to packagecom in JREsystemliabrary. test. tao; importjava. SQL. *; publicclassTest {publicstaticvoidmain (Stringargs []) {try {Class. forName ( quot; com. mysql. jdbc. driver quot;); System. out. print ( quot; database loaded successfully quot;); Strin mysqljdbcjava
The test code for the newly created java pro
InvalidLOCheader (badsignature) error and java. lang. ClassFormatError: com/mysql/jdbc Error
1. The error message is as follows:
SEVERE: Resource read error: Could not load org.springframework.jmx.support.MetricType.java.util.zip.ZipException: invalid LOC header (bad signature)
2. The error message is as follows:
12-31_12:00:15 com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@29579f4e -- Acqui
When using JDBC to connect to the MySQL database for data insertion, especially the mass data continuous insertion (10w+), how to improve efficiency?
In the JDBC programming interface, there are two methods that are particularly noteworthy: statement
void Addbatch () throws SQLException
Adds a set of parameters to this PreparedStatement object ' s b
See Lao Luo recently video, did a simple user register system. The user enters the user name, the real name, and the Password,servlet through the Web page (JSP) to save the information to MySQL via JDBC. Although it is a simple thing can not be simple, but small, perfectly formed, here do an induction and collation. The following first source code:First, index.jspThe results of its execution are as follows:
Tags: size basename search get state data connection 1.5 password differentThe JDBC connection data is a key point of javaweb development, and today we summarize and deepen our memory. The JDBC Connection database is divided into three steps: 1: Load Driver Need to download the respective drive jar package, you can go to the Internet search. Template: load driver: Class.forName (Driverclass); Different data
Label:First, create a database in MySQL, such as geek99db: Create Database geek99db; Use geek99db; Then create a table Customertab: CREATE TABLE Customertab (ID int primary key auto_increment,name Varcahr (), email varchar (20)); Show Table: Show tables; To add an element: Insert into CUSTOMERTBL (name,email) VALUES (' Tam ', ' [email protected] '); Display elements: Select *from customertbl; Second, complete the acquisition of the database under Ecpl
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.