在连接数据库的时候对数据库进行修改出现这样的异常:Table "test.customer" dose exist这是什么原因
在连接数据库的时候对数据库进行修改出现这样的错误:Table "test.customer" dose exist这是什么原因
@Test
public void testStatement() throws Exception {
// 1。获取数据库连接
Connection conn = GetConnection2();
// 2.准备插入SQL语句
String sql = "INSERT INTO customer (NAME, email, Birthday)"
+ " VALUES('sys','adaga@atguigu.con','2015-09-11')";
// 3.执行插入:①获取操作SQL语句的Statement 对象:
// 调用connection的createStatement()方法来获取
Statement statement = conn.createStatement();
// ②调用statement对象的executeUpdate(sql)执行SQL语句进行插入
statement.executeUpdate(sql);
// 关闭statement 对象
statement.close();
// 关闭连接
conn.close();
}
@Test
public void testGetConnection2() throws Exception{
System.out.println(GetConnection2());
}
public Connection GetConnection2() throws Exception {
String driverClass = null;
String jdbcUrl = null;
String user = null;
String password = null;
InputStream input =
getClass().getClassLoader().getResourceAsStream("jdbc.properties");
Properties properties = new Properties();
properties.load(input);
driverClass = properties.getProperty("driver");
jdbcUrl = properties.getProperty("jdbcUrl");
user = properties.getProperty("user");
password = properties.getProperty("Password");
Class.forName(driverClass);
Connection connection = DriverManager.getConnection(jdbcUrl, user, password);
return connection;
}
------解决思路----------------------
说表不存在啊,看下数据库表
------解决思路----------------------
你看下是不是你连接数据库的时候没有连接到你的myself数据库
------解决思路----------------------
你确定在test用户下有customer表,
@Test
public void testStatement() throws Exception {
// 1。获取数据库连接
Connection conn = GetConnection2();
// 2.准备插入SQL语句
String sql = "INSERT INTO customer (NAME, email, Birthday)"
+ " VALUES('sys','adaga@atguigu.con','2015-09-11')";
// 3.执行插入:①获取操作SQL语句的Statement 对象:
// 调用connection的createStatement()方法来获取
Statement statement = conn.createStatement();
// ②调用statement对象的executeUpdate(sql)执行SQL语句进行插入
statement.executeUpdate(sql);
// 关闭statement 对象
statement.close();
// 关闭连接
conn.close();
}
@Test
public void testGetConnection2() throws Exception{
System.out.println(GetConnection2());
}
public Connection GetConnection2() throws Exception {
String driverClass = null;
String jdbcUrl = null;
String user = null;
String password = null;
InputStream input =
getClass().getClassLoader().getResourceAsStream("jdbc.properties");
Properties properties = new Properties();
properties.load(input);
driverClass = properties.getProperty("driver");
jdbcUrl = properties.getProperty("jdbcUrl");
user = properties.getProperty("user");
password = properties.getProperty("Password");
Class.forName(driverClass);
Connection connection = DriverManager.getConnection(jdbcUrl, user, password);
return connection;
}
------解决思路----------------------
说表不存在啊,看下数据库表
------解决思路----------------------
你看下是不是你连接数据库的时候没有连接到你的myself数据库
------解决思路----------------------
你确定在test用户下有customer表,