JDBC connection to the MySQL database and example DBC is a technology developed by Sun that can connect to the database using Java language.
I. basic JDBC knowledge
JDBC (Java Data Base Connectivity, java database connection) is a Java API used to execute SQL statements.
JDBC: Javadatabaseconnectivity is how java connects to the database. Example of a static query: importjava. SQL. *; publicclasstest {staticStringdrivercom. mysql. jdbc. Driver; staticStringurljdbc: mysql: 10.108.27.48thunder; staticString
Java implementation of Mysql jdbc connection example bitsCN.com
First, create a database in the MySQL consoleSQL code
Create database test;Use test;Create table user (username varchar (15), password varchar (20 ));Insert into user values ('userone', '201312 ');You can also use MySQ
Label:Simple additions and deletions via JDBC (take MySQL for example)Directory Preface: What is JDBC I. Preparatory work (i): MySQL installation configuration and basic Learning Ii. preparatory Work (ii): Download the jar package for the database and import it Third,
Tags: class picture return images next sys MySQL Getting started username portJava simple additions and deletions via JDBC (take MySQL for example) Directory: Preface: What is JDBC I. Preparatory work (i): MySQL installation conf
Tags: nal www ase dstat tab Syntax exception tool orientedSimple additions and deletions via JDBC (take MySQL for example)Directory Preface: What is JDBC I. Preparatory work (i): MySQL installation configuration and basic Learning Ii. preparatory Work (ii): Download the jar
MySQL is used as an example to explain the JDBC database connection steps.
1. What is JDBC? What is the function?
Java Data Base Connectivity Java database connection protocol
It is a Java API used to execute SQL statements and provides unified access to multiple relational databases.
He provides a benchmark to build m
We have already seen that JDBC DriverManager can is used to get relational database connections. But if it comes to actual programming, we want more than just connections.Most of the times we is looking for loose coupling for connectivity so, we can switch databases easily, connection POOling for transaction management and distributed systems support. JDBC DataSource is the preferred approach if you be look
execute the statement efficiently several times.
Common methods
Boolean Execute ()
Executes the SQL statement in this PreparedStatement object, which can be any kind of SQL statement.
ResultSet ExecuteQuery ()
Executes the SQL query in this PreparedStatement object and returns the ResultSet object generated by the query.
int executeupdate ()
Executes the SQL statement in this PreparedStatement object, which must be a SQL data manipulation language (manipulation LANGUAGE,DML) st
1. What is JDBC and what is the effect?
Java Data Base Connectivity Java Database Connection protocol
is a Java API for executing SQL statements that provides uniform access to a variety of relational databases.
He provides a benchmark by which more advanced tools and interfaces can be built to enable developers to write database applications
With JDBC, it becomes easy to send SQL statements to variou
Label:MySQL Simple operationStart MySQL NetStart MySQL//login mysql-u root-P//CREATE DatabaseCreateDatabase mydb;CreateDatabaseTest Deleting a databaseDropDatabaseTest Working with databasesUse MyDB; Create a tableCreateTable MyTable (Namevarchar), Sexchar); Show all tables in the databaseShowTables Add a columnAlterTable MyTableAdd ageint InsertInsert MyTableVal
Label: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 to add the driver of the database, di
DirectoryPreface: What is JDBCI. Preparatory work (i): MySQL installation configuration and basic LearningIi. preparatory Work (ii): Download the jar package for the database and import itThird, JDBC Basic operation(1) Define the class of the record (optional)(2) access to the connection(3) Insert(4) Update(5) Select(6) DeleteIv. TestingFive, Code AnalysisSix, the question of thinkingPreface: What is JDBCIn
Label: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 to add the driver of the database, dif
object atStatement st =con.createstatement (); - //4. Execute SQL statements -String sql= "Select *from user";//querying all the information of the user table -ResultSet rs = st.executequery (SQL);//return result set after query - //5. Print out the results - while(Rs.next ()) { inSystem.out.println (rs.getstring ("Id") + "\ T" +rs.getstring ("name") + "\ T" +rs.getstring ("password"));} } toRs.close ();//Close Resource +Con.close (
statement.* The resultset object has a pointer to its current data row. Initially, the pointer is placed before the first line.* The next method moves the pointer to the next row;* Because this method returns false if there is no next row in the resultset object,* You can use it in the while loop to iterate the result set.**/Static connection conn = NULL;Public static connection getconnectionbyjdbc (){Try {// Load the driver packageClass. forname (COM. MySQ
1. What is JDBC? What's the role?Java data Base Connectivity Java Database Connection protocolis a Java API for executing SQL statements that provides unified access to a variety of relational databases.He provides a benchmark to build more advanced tools and interfaces that enable developers to write database applicationsWith JDBC, it's easy to send SQL statements to various relational data.In other words,
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.