我正在尝试通过 Eclipse 将数据输入到 MySQL 数据库中。这是我到目前为止所拥有的:
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import com.mysql.jdbc.Statement;
public class MySQL{
public static void main(String[] args)throws Exception{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/database","root","root");
PreparedStatement stmt = con.prepareStatement("INSERT INTO 'database'.'Table'(Account_ID,First_Name,Last_Name) VALUES ('hello12','Ed','Lee')");
ResultSet result = stmt.executeQuery();}
}
由于某种原因它不起作用......有什么想法吗?