//ResultSet rs= ps.executequery (); Traversal//Rtn=rs.next ();//If there is data to verify through//supplemental knowledge//Call stored procedure//CallableStatement Cs=conn.preparecall ("{
Call stored procedure name (?,?)} ");
Get information about the database DatabaseMetaData dm= conn.getmetadata ();
System.out.println ("Url=" +dm.geturl ()); System. OUT.PRINTLN ("name =" +dm.getusername ());
SYSTEM.OUT.PRINTLN ("Product name =" +dm.getdatabaseproductname ());
Metada
//Error statement: There is a syntax error near the keyword ' user '; - //user is the keyword in the SQL statement, if you want to use user as the table name, you must enclose the user in square brackets [], that is [user]; to + //processing result sets (including metadata); - //Print property name; theResultSetMetaData Rsmetadata =Resultset.getmetadata (); * for(inti = 1; I ) { $System.out.printf ("%-8s\t", Rsmetadata.getcolumnname (i));Panax N
Tags: mysql JDBC programming codeThe relationship between MySQL's JDBC Interface driver package version and MySQL version can be found on the official website, see below, there is no relevant description of JDBC version matching.Http://dev.mysql.com/doc/relnotes/connector-j/
Label:falsemysqldssoimpcache gretomatinull The use of Tomcat's JDBC Pooltomcat jdbc pool requires only 2 jar packages, Tomcat-jdbc.jar and Tomcat-juli.jar respectively, the two jar packages can be found in Tomcat7, Tomcat-jdbc.jar in the Tomcat directory, Tomcat-juli.jar in the bin directory. Http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/org.apache.
Document directory
Answer
Http://blog.csdn.net/pjchen/archive/2008/04/19/2308245.aspx
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.
words, JDKjava.sql.*Provides a series of interfaces, but does not provide any implementation (that is, class ). Therefore, anyone can write their own JDBC implementation (such as MySQL) under the interface specification ). If the caller only calls methods on the interface (for example, We), when there is any need for future changes (for
JDBC believe that everyone is not unfamiliar, as long as it is a Java, first contact with the EE is to learn such things, who called the program and the database to deal with it! And JDBC is a database dealing with a very basic knowledge, but also relatively close to the bottom, in the actual work we use more in fact or more mature framework, such as Hibernate, MyBatis.
But as these mature framework of the
=truecharacterEncoding=gbkautoReconnect=true failOverReadOnly=false
In the case of using a database connection pool, it is best to set the following two parameters:
autoReconnect=truefailOverReadOnly=false
It should be noted that in the XML configuration file, the symbol in the URL needs to be escaped to . For example, when configuring a database connection pool in Tomcat's server.xml, the MySQL
Jdbc connection to mysql database
Download the jdbc driver to the official website and place it under the relevant jdk directory, or add the jar file to the project
Package test_mysql; import java. SQL. *; import java. util. set; public class testjdbc {public static Connection getConnection () throws ClassNotFoundException, SQLException {String URL = "
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:JDB
After using amoeba, Cobar, dbware, and other read/write splitting components, one of my friends told me today that Mysql itself can also be read/write splitting, because they provide a new driver calledCom. MySQL. JDBC. replicationdriver
Description: http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-replication-connection.html
CodeExample:
I
Label:Java programs can be linked to the database through the JDBC, JDBC can easily access the database, do not have a specific database to write a special program. Need to configure Mysql-connector-java-5.0.8-bin.jar first The development process for connecting to a database using JDBC is as follows:
Registe
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 for the MyS
function and so on. Then I went to see the JDBC code. Found the Setfetchsize () method, the result is set, but it does not take effect, or there is an oom problem. My settings are as follows [Java]View PlainCopy
Ps=conn.con.preparestatement ("select * from bigTable");
Ps.setfetchsize (1000);
Later, in MySQL, I saw this approach: [Java]View PlainCopy
PS = (prepared
JDBC (Java Data Base Connectivity,java database connection) is a Java API for executing SQL statements that provides unified access to a variety of relational databases, consisting of a set of classes and interfaces written in the Java language. JDBC provides a benchmark to build more advanced tools and interfaces that enable database developers to write database applications.If you want to use the database
JDBC (Java Data Base Connectivity,java database connection) is a Java API for executing SQL statements that provides unified access to a variety of relational databases, consisting of a set of classes and interfaces written in the Java language. JDBC provides a benchmark to build more advanced tools and interfaces that enable database developers to write database applications.If you want to use the database
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.