Notice
Recent Posts
Recent Comments
Link
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Tags more
Archives
Today
Total
관리 메뉴

기초공사 (html,css,javascript)

mysql로 JDBC와 db연결 본문

게시판

mysql로 JDBC와 db연결

에스프레소라떼 2024. 1. 20. 16:04

1단계_드라이버 불러오기

Class.forName("cohttp://m.mysql.jdbc.Driver");
 

2단계_데이터베이스 연결

String dbUrl="jdbc:mysql://localhost:3306/jspdb5";

String dbUser="jspid";

String dbPass="jsppass";

Connection con=DriverManager.getConnection(dbUrl, dbUser, dbPass);

/*
다른분꺼
Class.forName("cohttp://m.mysql.jdbc.Driver");
String db_address = "jdbc:mysql://localhost:3306/pratice_board";
String db_username = "root";
String db_pwd = "root";

Connection connection = DriverManager.getConnection(db_address, db_username, db_pwd);

String insertQuery = "SELECT * FROM pratice_board.post order by num desc";
PreparedStatement psmt = connection.prepareStatement(insertQuery);
ResultSet result = psmt.executeQuery();%>
*/

'게시판' 카테고리의 다른 글

노트북으로 게시판 까지하는데 오류들..  (0) 2024.01.21
mariadb 오류들.  (0) 2024.01.20
JSTL까지 완성한 jsp 모든 코  (0) 2024.01.19
forward  (0) 2024.01.19
JSTL 적용한 list.jsp코드  (0) 2024.01.18