亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

建立的一個數據表,但是在運行時他總報錯You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'db' at line 1

Java代碼-------

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;


public class JDBCUtil {

private static final String URL="jdbc:mysql://127.0.0.1:3306/imooc";

private static final String USER="root";

private static final String PASSWORD="123456";

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

//1.加載驅動程序

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

//2.獲得數據庫的連接

Connection conn=DriverManager.getConnection(URL, USER, PASSWORD);

//3.通過數據庫連接操作數據庫,實現增刪查改

Statement stmt=conn.createStatement();

//查詢imooc_goddess里面的user_name,age

ResultSet rs=stmt.executeQuery("select user_name,age form imooc_goddess");

while(rs.next()){//為真,則有數據

System.out.println(rs.getString("user_name")+","+rs.getInt("age"));

}

}

}

數據表:

CREATE TABLE `db` (

? `id` int(11) NOT NULL AUTO_INCREMENT,

? `user_name` varchar(30) NOT NULL,

? `sex` int(11) DEFAULT NULL,

? `age` int(11) DEFAULT NULL,

? `birthday` date DEFAULT NULL,

? `email` varchar(30) DEFAULT NULL,

? `mobile` varchar(11) DEFAULT NULL,

? `create_user` varchar(30) DEFAULT NULL,

? `create_date` date DEFAULT NULL,

? `update_user` varchar(30) DEFAULT NULL,

? `update_date` date DEFAULT NULL,

? `isdel` int(11) DEFAULT NULL,

? PRIMARY KEY (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

SET character_set_client="utf8";

SET character_set_connection="utf8";

SET character_set_results="utf8";

自己手動添加了一條信息

正在回答

2 回答

我也是。。

0 回復 有任何疑惑可以回復我~

sb了 ? ? 當時看了半天 ? 原來是手賤。。。。。字母打錯了select user_name,age form imooc_goddess中from。。。。郁悶。。。。。。。。。。。。。。。。。。。。。。。。。。

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

建立的一個數據表,但是在運行時他總報錯You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'db' at line 1

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號