JDBC

ClassNorFoundException:com.mysql.jdbc.Driver

从官网下载connector/J,解压或者安装,构建路径

Access denied for user ‘‘@‘localhost‘ (using password: NO)

url路径错误。

附上2018-11-29的代码

import java.sql.*;

public class Demo {
 public static final String URL = "jdbc:mysql://localhost:3306/rank";
 public static final String USER = "root";
 public static final String PASSWORD = "156321";
 
 
 public void connect()throws Exception
 {
  Class.forName("com.mysql.jdbc.Driver");//com.mysql.cj.jdbc.Driver
  Connection conn = DriverManager.getConnection(URL,USER,PASSWORD);
  Statement stmt = conn.createStatement();
  ResultSet rs = stmt.executeQuery("SELECT * FROM ranks");
  //System.out.println("hello");
  while(rs.next())
  {
   System.out.println(rs.getString("Rank")+" "+rs.getString("Score"));
  }
 }
 public static void main(String[] args)
 {
  Demo d = new Demo();
  try{
   d.connect();
  }
  catch(Exception e)
  {
   e.printStackTrace();
   System.out.println("Something wrong!");
  }
  
 }
}

sql 代码

error 1175

set SQL_SAFE_UPDATES = 0;

where / order by

select * from ranks where day_=1 order by score DESC;
#由大到小排序,默认由小到到,
#where在order by 前

delete

delete from ranks where Name_Ball=‘BOO‘;
#delete from 表名称 where 列名称 = 值;

drop

drop database sys;
drop table rank;

JDBC

上一篇:遇到报错:mount /dev/sdb on /mnt failed: Structure needs cleaning


下一篇:Report Server Configuration Manager报表服务器配置管理器,连接新数据库-》报错:无法连接到服务器。