JDBC连接MySQL数据库关键的四个步骤
JDBC连接MySQL数据库关键的四个步骤 http://www.mesfr.com
一、查找驱动程序
MySQL目前提供的Java驱动程序为Connection/J,可以从MySQL官方网站下载,并找到mysql-connector-java-3.0.15-ga-bin.jar文件,此驱动程序为纯Java驱动程序,JDBC链接MySQL不需做其他配置。
二、动态指定classpath
如果需要执行时动态指定classpath,就在执行时采用-cp方式。否则将上面的.jar文件加入到classpath环境变量中。
三、加载JDBC 连接MySQL
try{
Class.forName(com.mysql.jdbc.Driver);
System.out.println(Success loading Mysql Driver!);
}catch(Exception e)
{
System.out.println(Error loading Mysql Driver!);
e.printStackTrace();
}
四、设置JDBC连接MySQL的URL4、设置JDBC连接MySQL的URL
jdbc:mysql://localhost/databasename[?pa=va][&pa=va]
相关文档:
START TRANSACTION, COMMIT和ROLLBACK语法
START TRANSACTION | BEGIN [WORK]
COMMIT [WORK] [AND [NO] CHAIN] [[NO] RELEASE]
ROLLBACK [WORK] [AND [NO] CHAIN] [[NO] RELEASE]
SET AUTOCOMMIT = {0 | 1}
START
TRANSACTION或BEGIN语句可以开始一项新的事务。COMMIT可以提交当前事务,是变更成为永久变更。ROLLBACK ......
1 innochecksum
5 msql2mysql
6 myisamchk
7 myisam_ftdump
8 myisamlog
9 &nbs ......
drop table student;
create table student
(sno int not null unique,
sname varchar(8) not null,
ssex char(2) not null,
sage int ,
sdept varchar(20));
select * from student;
alter table student drop uniq ......
Backup and Restore MySQL Database Using mysqldump
by Ramesh Natarajan on September 22, 2008ShareThis
[mysqldump - MySQL Backup & Restore]mysqldump is an effective tool to backup MySQL database. It creates a *.sql file with DROP table, CREATE table and INSERT into sql-statements of the source ......
问题:远程连接服务器的数据库
$ mysql -hserverip -uuser -ppassword
ERROR 1045 (28000): Access denied for user 'user'@'localhost'
(using password: YES)
原因:mysql.user表中没有设置远程连接
$ mysql -uroot -ppassword #用root用户在server上登录
mysql> select host, user, password from mysql ......