import static java.lang.System.out;
import java.sql.*;
public class ConnMySql
{
public static void main(String[] args) throws Exception
{
Class.forName("com.mysql.jdbc.Driver");
try
(
Connection conn = DriverManager.getConnection("jdbc.mysql://127.0.0.1:3306/select_test"
, "root", "MaYG191001&&");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select s.*, teacher_name"
+ " from student_table s, teacher_table t"
+ " where t.teacher_id = s.java_teacher")
)
{
while(rs.next())
{
out.println(rs.getInt(0) + "\t"
+ rs.getString(1) + "\t"
+ rs.getString(2) + "\t"
+ rs.getString(3));
}
}
}
}
当我运行此程序时,它在下面抛出异常:
我的Java版本是jase 11