最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

java連接mysql運(yùn)行報(bào)錯(cuò)

package?com;

import?java.sql.Statement;
import?java.sql.Connection;
import?java.sql.DriverManager;
import?java.sql.ResultSet;

public?class?QuerTest?{

	public?static?void?main(String[]?args)?throws?Exception?{
		//連接數(shù)據(jù)庫的url
		String?url?=?"jdbc:mysql://127.0.0.1:5653/wuzydb";
		//數(shù)據(jù)庫用戶名
		String?user?=?"root";
		//數(shù)據(jù)庫密碼
		String?password?=?"1111";
		
		//1、加載驅(qū)動(dòng)
		Class.forName("com.mysql.jdbc.Driver");
		//2、創(chuàng)建數(shù)據(jù)庫連接對(duì)象
		Connection?conn?=?DriverManager.getConnection(url,?user,?password);
		//3、創(chuàng)建Statement對(duì)象
		Statement?stmt?=?conn.createStatement();
		//4、獲取ResultSet
		String?sql?=?"select?name,salary,age?from?t_emp";
		ResultSet?rs?=?stmt.executeQuery(sql);
		
		while?(rs.next())?{
			//獲取字段name數(shù)據(jù)
			String?name?=?rs.getString("name");
			//獲取字段salary
			double?salary?=?rs.getDouble("salary");
			//獲取age數(shù)據(jù)
			int?age?=?rs.getInt("age");
			
			System.out.println(name+?","?+salary+?","?+age);
		}
		
		//5、關(guān)閉數(shù)據(jù)庫
		rs.next();
		stmt.close();
		conn.close();
	}

}

http://img1.sycdn.imooc.com//5725811800012c1607470229.jpg

正在回答

1 回答

你有在項(xiàng)目中添加mysql驅(qū)動(dòng)的jar包嗎?


0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

影色 提問者

此問題已解決,原因是我jar包導(dǎo)入錯(cuò)誤,感謝您的幫助
2016-05-03 回復(fù) 有任何疑惑可以回復(fù)我~
#2

影色 提問者

非常感謝!
2016-05-03 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

java連接mysql運(yùn)行報(bào)錯(cuò)

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)