teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

コード修正

2021/05/13 05:25

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -3,23 +3,9 @@
3
3
 
4
4
 
5
5
  ```Java
6
- package JDBC;
7
6
 
8
- import java.sql.Connection;
9
- import java.sql.DriverManager;
10
- import java.sql.PreparedStatement;
11
- import java.sql.SQLException;
12
- import java.sql.Statement;
13
- import java.text.ParseException;
14
- import java.text.SimpleDateFormat;
15
- import java.util.Scanner;
16
- import java.util.regex.Matcher;
17
- import java.util.regex.Pattern;
18
7
 
19
- public class DBsend {
20
8
 
21
- public static void main(String[] args) {
22
-
23
9
  final String URL = "jdbc:postgresql://localhost:5432/education?serverTimezone=JST";
24
10
  final String USERNAME = "postgres";
25
11
  final String PASSWORD = "postgres";
@@ -33,7 +19,6 @@
33
19
  String sal = null;
34
20
  String comm = null;
35
21
  String deptno = null;
36
-
37
22
  int x = 0;
38
23
 
39
24
  Scanner scanner = new Scanner(System.in);
@@ -93,81 +78,9 @@
93
78
 
94
79
  }
95
80
 
96
- System.out.println("名前を入力してくだい。");
81
+ //各項目データ入力させる
97
- ename = new Scanner(System.in).nextLine();
98
-
99
- while (true) {
82
+               //コードは省略してます
100
- System.out.println("名前のフリガナを入力してください。");
101
- yomi = new Scanner(System.in).nextLine();
102
-
103
- if (yomi.matches("^[\u30A0-\u30FF]+$")) {
104
- break;
105
- } else {
106
- System.out.println("カタカナで入力してください。");
107
- }
108
83
  }
109
-
110
- System.out.println("役職を入力してください。");
111
- job = new Scanner(System.in).nextLine();
112
-
113
- System.out.println("上司を入力してください。");
114
- mgr = new Scanner(System.in).nextLine();
115
-
116
- while (true) {
117
- System.out.println("入社日を入力してください。(yyyy/MM/dd)");
118
- hiredate = new Scanner(System.in).nextLine();
119
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
120
- sdf.setLenient(false);
121
-
122
- try {
123
- sdf.parse(hiredate);
124
- break;
125
- } catch (ParseException e) {
126
- System.out.println("正しい日付ではありません");
127
- }
128
- }
129
-
130
- while (true) {
131
- System.out.println("給与を入力してください。");
132
- sal = new Scanner(System.in).nextLine();
133
-
134
- Pattern p = Pattern.compile("^[0-9]*$");
135
- Matcher m = p.matcher(sal);
136
-
137
- if (m.matches()) {
138
- break;
139
- } else {
140
- System.out.println("数字で入力してください。");
141
- }
142
- }
143
-
144
- while (true) {
145
- System.out.println("インセンティブを入力してください。");
146
- comm = new Scanner(System.in).nextLine();
147
-
148
- Pattern p = Pattern.compile("^[0-9]*$");
149
- Matcher m = p.matcher(comm);
150
-
151
- if (m.matches()) {
152
- break;
153
- } else {
154
- System.out.println("数字で入力してください。");
155
- }
156
- }
157
-
158
- while (true) {
159
- System.out.println("部署ナンバーを入力してください。");
160
- deptno = new Scanner(System.in).nextLine();
161
-
162
- Pattern p = Pattern.compile("^[0-9]*$");
163
- Matcher m = p.matcher(deptno);
164
-
165
- if (m.matches()) {
166
- break;
167
- } else {
168
- System.out.println("数字で入力してください。");
169
- }
170
- }
171
84
  //SQL文で入力させたデータを入れていく
172
85
  String sql = "INSERT INTO EDUCATION.EMPLOYEES VALUES (" + "'" + empno + "'," + "'" + ename
173
86
  + "',"

1

タイトル要件追加

2021/05/13 05:24

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- Java DB接続 JDBC
1
+ Java 主キー制約を書きたい
body CHANGED
File without changes