First import the MySQL driver jar package1. The first method Public classDemo1 {//JDBC Protocol: Database sub-protocol://Host: Port number/connected database PrivateString url = "Jdbc:mysql://localhost:3306/test"; PrivateString user = "root"; PrivateString password = "root"; @Test Public voidtest1 () {Driver Driver=NewCom.mysql.jdbc.Driver (); Properties Props
1. Database creation1 --Create a database2 Create Databasejdbc;3 --Call Database4 Usejdbc;5 --Create user Table6 Create Table User7 (8Idinteger not NULLAuto_increment,9Namevarchar( $) not NULL,TenBirthday Date not NULL, One Money float not NULL, A Primary Key(ID) - ); - --Inserting Data the Insert into User(Name,birthday, Money)Values('Zhangs','1985-01-01', -); - Insert into User(Name,birthday,
//when JDBC closes a database connection, it implies a commit transaction operation private final static String Db_driver="Oracle.jdbc.driver.OracleDriver"; Private final static String db_connection="Jdbc:oracle:thin:@127.0.0.1:1521: Mydb01 "; Private final static Stringdb_name ="Scott"; Private final static String Db_pwd="Scott"; //
("SQLException:" + ex. getMessage ());// Display database connection error or query Error}}}//###################################### #####################// Code ended//###################################### #####################In the above procedure I Want you to demonstrate how to use a JDBC-ODBC to connect to a database
This article is just a summary of my younger brother's experience.
Although Java JDBC is used to connect to the database, it is difficult to have a certain MySQL Foundation. Here, I suggest using command line input,
Familiar with the syntax, the graphical interface is not very suitable for beginners. After all, familiar statements are king!
Here, I will only introduce the commonly used MySQL statements. Yo
In JDBC, check and add, delete, modify, and query mysql database connection tools such as Java, and jdbcmysql
First, write a tool class that implements MySQL database connection, and closes the database
Reprinted from: http://www.jb51.net/article/31876.htm1. If MyEclipse has been able to develop the Java project normally 2. Install MySQL The individual is using the version is Mysql-5.0.22-win32.zip Website: http://www.mysql.com/downloads/mysql/#downloads 3. Download the JDBC driver Personal use of the mysql-connector-java-5.1.22.zip, what is needed is the Mysql-connector-java-5.1.22-bin.jar after decompressionWebsite: http://www.mysql.com/downloads/c
{ Public Static FinalString dbdriver = "Org.gjt.mm.mysql.Driver";//Drive Path
Public Static FinalString Dburl = "Jdbc:mysql://localhost:3306/demo";//Database Path
Public Static FinalString USER = "root";//User name
Public Static FinalString PASSWD = "Changme";//Password
Public Static FinalString SQL = "SELECT * from rj144";//SQL statement to be executed
Public Static voidMain (string[] args)throwsexception{//TODO auto-generat
The two days have all been spent here. In fact, this is not a very complicated thing, but I have been engaged for a long time.
First, download the jdbc SQL Server Driver.
Then, test MSSQLServer. jar, msbase. jar, and msutil. Jar under tomcat/common/lib.A problem occurs here. Because jcreater is used. The three files are not set to the class library called by jcreater, so there is no prompt when using them.
The main reason for this time is that the
Tags: read classpath str img int 1.5 output WAN SelectSpark's JDBC Development (Connection Database test)
the following actions belong to local mode operations:1, establish the project RDDTOJDBC in Eclipse4.5, and create a folder lib for placing third-party driver packages[Email protected] software]$ cd/project/rddtojdbc/[Email protected] rddtojdbc]$ mkdir-
encapsulate frequently used JDBC database connections into a class that can be invoked directly when used.
disadvantages such as the following:
The speed of access to data records has been affected to a certain extent;
Changing the data source is difficult: JDBC supports multiple databases, and the operations between the various databases are d
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.