Java连接到数据库db01,给数据库db01中的表actor添加一条语句,
没有报错,也能正常运行,但是添加的汉字字段姓名、性别两列在数据库中显示的是‘?’
出现这种问题是什么原因呢?
public class jdbc01 {
public static void main(String[] args) throws SQLException {
//1.注册驱动
Driver driver = new Driver();
//2.得到链接
String url = "jdbc:mysql://localhost:3306/db01";
Properties properties = new Properties();
properties.setProperty("user","root");
properties.setProperty("password","123456");
Connection connect = driver.connect(url,properties);
//3."
String sql="insert into actor values(null,'刘德华','男','1999-02-19','123')";
Statement statement = connect.createStatement();
int rows = statement.executeUpdate(sql);
System.out.println(rows > 0 ? "成功" : "失败");
statement.close();
connect.close();
}
}