-1.配置数据库:http://www.cnblogs.com/sshoub/p/4321640.html

2.创建可以远程的登录用户:http://www.cnblogs.com/xyzdw/archive/2011/08/11/2135227.html

grant all privileges on *.* to testuser@"%" identified by "password" ;

3.数据库操作:

  •  创建数据库以及表
DROP TABLE
IF EXISTS mq_message_content;

CREATE TABLE mq_message_content (
    task_id VARCHAR (255) NOT NULL CHECK (task_id != ''),
    type VARCHAR (255) NOT NULL,
    msgcontent LONGTEXT NOT NULL,
    time VARCHAR (50) NOT NULL,
    PRIMARY KEY (task_id, type)
) DEFAULT CHARSET = 'utf8';

 4. Java代码连接数据库,进行相应的操作

Class.forName(dbDriver).newInstance();
Connection conn = DriverManager.getConnection(dbUrl, dbUsername, dbPassword);
PreparedStatement pst = conn.prepareStatement(sql);

 

相关文章:

  • 2022-01-11
  • 2021-08-05
  • 2022-12-23
  • 2021-11-23
  • 2022-01-04
  • 2021-04-13
  • 2021-07-12
  • 2022-12-23
猜你喜欢
  • 2021-11-28
  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
  • 2021-07-20
  • 2021-12-19
  • 2021-05-29
相关资源
相似解决方案