Home > Database > Mysql Tutorial > Ubuntu下进行基于MySQL的JDBC的开发

Ubuntu下进行基于MySQL的JDBC的开发

WBOY
Release: 2016-06-07 16:53:09
Original
1081 people have browsed it

安装环境:Ubuntu Linux1、先安装JDK2、安装MySQL的JDBC驱动程序Connector/J(1)Ubuntu新立得软件管理包里面搜索Connector/J

安装环境:Ubuntu Linux

1、先安装JDK

2、安装MySQL的JDBC驱动程序Connector/J

(1)Ubuntu新立得软件管理包里面搜索Connector/J

(2)找到之后安装

(3)找到mysql-connector-java-n.n.n这个文件在ubuntu下放在/usr/lib/java下面(?),装它拷贝到你的java安装目录,ubuntu下的java只是一个链接文件,所以应该考到/usr/lib/jvm/java-6-sun/jre/lib/ext

3、在进行jdbc链接时,,首先要装载Connector/J driver可以用语句:Class.forName("com.mysql.jdbc.Driver").getInstance();

4、创建一个链接:Connection con = DriverManager.getConnection(url,username,password);

其中url采用以下型式:

jdbc:mysql://主机名/数据库名?characterEncoding=utf8

username是能够登陆到数据库并对其进行操作的用户名,在mysql中进行设定

password是对应用户名对应的登陆密码。

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template