アプリ版:「スタンプのみでお礼する」機能のリリースについて

mysqlのテーブルは
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
mysql> show tables;
+----------------------+
| Tables_in_helloworld |
+----------------------+
| test |
+----------------------+
1 row in set (0.03 sec)

mysql> desc test;
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| helloworld | varchar(255) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
1 row in set (0.03 sec)
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー

こうなっていて
eclipseのコードは

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

public class MyQuery {

public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ

Connection conn = null;
String url = "jdbc:mysql://localhost/helloworld?useSSL=false&requireSSL=false";
String user = "root";
String password = "password";
String msg = "";

try {
// ドライバロード
Class.forName("com.mysql.cj.jdbc.Driver");

// MySQLに接続
conn = DriverManager.getConnection(url, user, password);

// ステートメント生成
Statement stmt = conn.createStatement();

// SQLを実行
String sqlStr = "SELECT * FROM test";
ResultSet rs = stmt.executeQuery(sqlStr);

// 結果行をループ
while(rs.next()){
// レコードの値
int Field = rs.getInt("Field");

//表示
System.out.println(Field);
}

// 接続を閉じる
rs.close();
stmt.close();
}catch (ClassNotFoundException e){
msg = "ドライバのロードに失敗しました";
System.out.println(msg);
e.printStackTrace();
}catch (Exception e){
msg = "ドライバのロードに失敗しました";
System.out.println(msg);
e.printStackTrace();
}
}
}
ーーーーーーーーーーーーーーーーーーーー
こうなっていて実行してもエラーも結果も何も表示されないのですが
理由がわかりませんだれか教えてください。

A 回答 (1件)

で、テーブルに行はあるのですか?

    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!