Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
db_studies
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Deokhyun Lee
db_studies
Commits
fdb013f6
Commit
fdb013f6
authored
Dec 03, 2021
by
Deokhyun Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added logIn and singUpForm methods
parent
553b95fc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
0 deletions
+72
-0
.gitignore
.gitignore
+1
-0
MemberDaoImpl.java
src/dao/MemberDaoImpl.java
+61
-0
MainClass.java
src/member/MainClass.java
+10
-0
No files found.
.gitignore
View file @
fdb013f6
...
@@ -9,3 +9,4 @@
...
@@ -9,3 +9,4 @@
/db_java.iml
/db_java.iml
/.idea/
/.idea/
/src/dao/DBCode.java
/src/dao/DBCode.java
out/
\ No newline at end of file
src/dao/MemberDaoImpl.java
View file @
fdb013f6
...
@@ -27,6 +27,7 @@ public class MemberDaoImpl implements MemberDao {
...
@@ -27,6 +27,7 @@ public class MemberDaoImpl implements MemberDao {
}
}
}
}
@Override
@Override
public
void
insert
(
MemberDto
dto
)
{
public
void
insert
(
MemberDto
dto
)
{
String
sql
=
"INSERT INTO mytestdb.major_table (name, major, email) VALUES (?, ?, ?)"
;
String
sql
=
"INSERT INTO mytestdb.major_table (name, major, email) VALUES (?, ?, ?)"
;
...
@@ -100,4 +101,64 @@ public class MemberDaoImpl implements MemberDao {
...
@@ -100,4 +101,64 @@ public class MemberDaoImpl implements MemberDao {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
public
void
insertSignUpForm
(
String
name
,
String
major
,
String
email
,
String
password
)
{
String
sql
=
"INSERT INTO mytestdb.major_table (name, major, email, password) VALUES (?, ?, ?,?)"
;
PreparedStatement
pstmt
=
null
;
try
{
pstmt
=
conn
.
prepareStatement
(
sql
);
ResultSet
rs
=
pstmt
.
executeQuery
();
while
(
rs
.
next
())
{
if
(
rs
.
getString
(
"email"
).
equals
(
name
))
{
System
.
out
.
println
(
"Email already exists in the database."
);
break
;
}
}
pstmt
.
setString
(
1
,
name
);
pstmt
.
setString
(
2
,
major
);
pstmt
.
setString
(
3
,
email
);
pstmt
.
setString
(
4
,
password
);
int
result
=
pstmt
.
executeUpdate
();
if
(
result
==
1
)
{
System
.
out
.
println
(
"회원가입 성공!"
);
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"회원가입 실패!"
);
}
finally
{
try
{
if
(
pstmt
!=
null
&&
!
pstmt
.
isClosed
())
{
pstmt
.
close
();
}
}
catch
(
Exception
e2
)
{
}
}
}
public
void
logIn
(
String
email
,
String
password
){
String
sql
=
"SELECT * FROM mytestdb.major_table"
;
PreparedStatement
pstmt
=
null
;
try
{
pstmt
=
conn
.
prepareStatement
(
sql
);
ResultSet
rs
=
pstmt
.
executeQuery
();
while
(
rs
.
next
())
{
if
(
rs
.
getString
(
"email"
).
equals
(
email
)
&&
rs
.
getString
(
"password"
).
equals
(
password
)){
System
.
out
.
println
(
"로그인 성공!"
);
}
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"logIn 메서드 예외발생"
);
}
finally
{
try
{
if
(
pstmt
!=
null
&&
!
pstmt
.
isClosed
())
{
pstmt
.
close
();
}
}
catch
(
Exception
e2
)
{
}
}
}
}
}
\ No newline at end of file
src/member/MainClass.java
View file @
fdb013f6
package
member
;
package
member
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Scanner
;
import
dao.MemberDaoImpl
;
import
dao.MemberDaoImpl
;
import
dto.MemberDto
;
import
dto.MemberDto
;
...
@@ -22,7 +23,16 @@ public class MainClass {
...
@@ -22,7 +23,16 @@ public class MainClass {
// 데이터 보기
// 데이터 보기
System
.
out
.
println
(
memberDao
.
selectAll
());
System
.
out
.
println
(
memberDao
.
selectAll
());
// 데이터 수정
// 데이터 수정
System
.
out
.
println
(
"1 로 회원가입; 2 로 로그인"
);
Scanner
sc
=
new
Scanner
(
System
.
in
);
int
num
=
sc
.
nextInt
();
sc
.
nextLine
();
if
(
num
==
1
){
}
else
if
(
num
==
2
){
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment