问答详情
源自:2-2 JDBC实战---打通数据库

您的SQL语法有错误?????

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;



public class Skt {


/**

* @param args

*/

//JDBC

private static final String DB_URL = "jdbc:mysql://localhost:3306/association?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8";

private static final String USERNAME="root";

private static final String PASSWORD="135511";

 

public static void main(String[] args) throws Exception {

Class.forName("com.mysql.cj.jdbc.Driver");

Connection con= DriverManager.getConnection(DB_URL, USERNAME, PASSWORD);

Statement stmt=con.createStatement();

ResultSet rt= stmt.executeQuery("select name ,url form websites ");

while(rt.next()){

System.out.println(rt.getString("name")+","+rt.getString("url"));

}

System.out.println("Goodbye!");

}

       


}


提问者:慕移动2145274 2019-03-19 22:34

个回答

  • 慕移动2145274
    2019-03-19 22:41:25

    知道了,from打成form了