, returning the ResultSet objectThe Executeupdate () method executes an INSERT, UPDATE, or DELETE statement of SQL, returning an int value that gives the number of rows that are affectedSuch as:Statement st=con.createstatement ();ResultSet rs=st.executequery ("SELECT * from students");2) PreparedStatement object: Allows parameterized queries to be executedSuch as:String sql= "SELECT * from students where stuid=?";PreparedStatement ps=con.preparestatement (SQL);Ps.setstring (1, "56789");//Set the
1. Create the database users (Integer id, String name, String pass, String sex, Integer age) in mysql. 2. hierarchical implementation: cn. csdn. web. util encapsulates the Connction object cn. csdn. web. domain encapsulates the Entity bean cn. csdn. web. dao encapsulation interface and interface implementation class cn. csdn. web. the junit test class first uses the standalone mode to create a Connection object (remember to put the driver jar package in the lib folder) cn. csdn. web. util encaps
statements, so you might want to roll back to a particular point in the transaction. The JDBC savepoint helps us create checkpoints (checkpoint) in the transaction so that we can roll back to the specified point. When a transaction commits or the entire transaction is rolled back, any savepoint generated for the transaction is automatically freed and becomes invalid. Rolling a transaction back to a savepoint causes all other savepoint to be automatic
=jar-dfile= Ojdbc7.jarThen it's still a mistake.Later I found the cause of the error because I was under windows and I ran this section of the program on the GIT command line that was opened.Open the Windows command-line interface, enter the ~/additional_jars/directory, and then run:MVN install:install-file-dgroupid=com.oracle-dartifactid=ojdbc7-dversion=12.1.0.2-dpackaging=jar-dfile= Ojdbc7.jarShow "BUILD SUCCESS".You can then add dependency to the MAVEN project, and the coordinates correspond
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) UNSIGNED not NULL auto_increment, ' NAME ' VARCHAR
Tags: res UI operations master Class data port prepare interactionFirst, the concept of JDBC 1. JDBC (Java database Connectivity) Java DB connection A) API support primarily for Java database applications 2, the main function of JDBC
This cainiao is involved in Java. I am not in a rush to look at the basic syntax, the features of some Java versions, or some promotion knowledge, because there is one thing. net (OOP) programming ideas, so you can find and learn these Java syntaxes and what they are used. I can't wait to use JAVA to add, delete, modif
//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
so on? The answer is yes. In fact, the so-called three frameworks, which are only highly encapsulated, make development easier, more convenient, and more efficient, while the real core is the knowledge of JDBC and servlets. STRUTS2 is actually encapsulated on the basis of a servlet, and hibernate is a highly encapsulated JDBC that transforms relational-oriented data operations into object-oriented programm
to describe the beginning of a thing, just commit or roll back each transaction. However, each transaction is still explicitly ended with commit or rollback. After the connection sets the implicit transaction mode to open, an implicit transaction is automatically started when the database Engine instance executes any of the following statements for the first time: Alter Table,insert,create,open, Delete,revoke, Drop,select, Fetch, truncate table,grant,update The transaction will remain in effect
Before we know about JDBC, we can make a review of ODBC to better understand JDBC. See the name also know that these two relationships are not general, they achieve the same function, for the application connection and operation of the database support. So, let's start with ODBC.
Odbc
ODBC (Open Database Connectivity) is a short name for open databases interconnection, an application interface that uses S
, Simply write the program once to make it run on any platform. Such as: How do you use JDBC?The main functions of JDBC are as follows:
Establish a connection to a database or other data source
Sending SQL commands to the database
Processing the returned results of the database
Here is an example of a
in practical applications, a report with a large amount of data often needs to be taken out of the database at a time when it is presented or exported, and the slow fetch speed of JDBC makes the process extremely inefficient. How to optimize the fetch speed becomes the key to improve the performance of the report. In the run-dry set calculation report, the performance of the JDBC fetch can be improved by pa
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.