【发布时间】:2020-07-24 15:29:42
【问题描述】:
这是我的代码,当我按下可运行文件时,我什么也没得到(已连接) 我想展示名称中包含“DM”的玩具
import java.sql.*;
public class Toy {
public static void main(String args[]) throws Exception {
String query = "SELECT ToyName, Price, color from Toy WHERE ToyName='DM '";
System.out.println("concected");
Connection c=DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\96650\\Documents\\toy.accdb");
Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery(query);
while(rs.next()) {
String desc = rs.getString("ToyName");
String color = rs.getString("Color");
double price=rs.getDouble("Price");
System.out.println(desc+" Color: "+color+"\n $"+price);}}}
【问题讨论】: