Ubuntu下使用安装和使用MYSQL和JDBC
来源:互联网 发布:云计算 智慧园区 编辑:程序博客网 时间:2024/06/18 18:36
JDBCAndMySQL
#####################################################33
1.安装MYSQL,JDBC
sudo apt install mysql-client mysql-server libmysql-java打开~/.bashrc文件,添加CLASSPATH,然后更新源文件,并查看环境变量设置情况。sudo geany ~/.bashrc CLASSPATH = $CLASSPATH:/usr/share/java/mysql.jarsource ~/.bashrcecho $CLASSPATH
2. 配置
#登录主用户,设置密码mysql -uroot -p#创建数据库 create database webmagic;#新增用户 grant all privileges on webmagic.* to auss@localhost identified by "auss"; flush privileges;#测试新用户mysql -uauss -h 127.0.0.1 -p
3. 在Java里面测试
import java.sql.*;import java.util.Properties;public class DBDemo{ // The JDBC Connector Class. private static final String dbClassName = "com.mysql.jdbc.Driver"; // Connection string. emotherearth is the database the program // is connecting to. You can include user and password after this // by adding (say) ?user=paulr&password=paulr. Not recommended! private static final String CONNECTION = "jdbc:mysql://127.0.0.1/webmagic"; public static void main(String[] args) throws ClassNotFoundException,SQLException { System.out.println(dbClassName); // Class.forName(xxx) loads the jdbc classes and // creates a drivermanager class factory Class.forName(dbClassName); // Properties for user and password. Here the user and password are both 'paulr' Properties p = new Properties(); p.put("user","auss"); p.put("password","auss"); // Now try to connect Connection c = DriverManager.getConnection(CONNECTION,p); System.out.println("It works !"); c.close(); }}
0 0
- Ubuntu下使用安装和使用MYSQL和JDBC
- ubuntu下mysql的安装和使用
- ubuntu下安装mysql数据库和使用
- Ubuntu下安装mysql和使用
- Ubuntu下Mysql数据库的安装和使用
- Ubuntu下MySql源码包安装、配置和使用
- Ubuntu navicat for mysql 安装和使用
- mysql和jdbc的使用
- ubuntu下tftp安装和使用
- ubuntu下tftp安装和使用
- ubuntu下安装和使用wxwidgets库
- ubuntu linux下安装和使用PPS
- Ubuntu下svn安装和使用 .
- ubuntu下安装subversion客户端和使用
- Ubuntu下安装和使用wireshark
- ubuntu下sphinx 安装和使用过程
- ubuntu下ice的安装和使用
- ubuntu下nginx安装和使用
- Git 详解
- 通过handler更新UI的疑问
- 用ftp方式下载文件,怎么得到正在下载文件的大小啊
- 2017_01_02_1_静态绑定
- 一个recyclerView实现linear和Grid的布局
- Ubuntu下使用安装和使用MYSQL和JDBC
- 多客户端传感器数据采集系统
- (4.1.45) Android RecyclerView 使用完全解析 体验艺术般的控件
- 使用NMF模型进行消费者行为分析.
- 2017_01_02_1_源码阅读--BaseYii.php
- nose1.3.7文档翻译--3.Writing tests
- android 实现视频缓存
- 2017_01_02_1_类自动加载
- Struts2 创建Action对象并放入ValueStack的时机