wasup
게시판 만들기#ver1_basedata 본문
반응형
기초데이터입력
ConnectionInfo.java
package control;
public class ConnectionInfo {
public static String DBIP = "localhost";
public static String DBPort = "3306";
public static String DBName = "boardtest";
public static String DBID = "root";
public static String DBPASSWORD = "1234";
}
basedata.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="control.ConnectionInfo" %>
<%
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection DBConManagement = DriverManager.getConnection(String.format("jdbc:mysql://%s:%s/%s?useUnicode=true&characterEncoding=utf8", ConnectionInfo.DBIP, ConnectionInfo.DBPort, ConnectionInfo.DBName), ConnectionInfo.DBID, ConnectionInfo.DBPASSWORD);
Statement CommandState = DBConManagement.createStatement();
for(int num = 1; num<=332; num++){
String setSQL = String.format("INSERT INTO boardtable(boTit, boCon) VALUES('title%d', 'content%d')", num, num);
CommandState.executeUpdate(setSQL);
}
DBConManagement.close();
System.out.println("입력 완료");
} catch (Exception e) {
e.printStackTrace();
}
%>
반응형
'IT > Java' 카테고리의 다른 글
Java) 객체는 무엇이고 클래스는 무엇인가? (0) | 2021.05.31 |
---|---|
게시판 만들기#ver1_paging (0) | 2021.05.30 |
게시판 만들기#ver1_list and view (0) | 2021.05.28 |
게시판 만들기#ver1_write (0) | 2021.05.27 |
Java) Scanner test (0) | 2021.05.15 |
Comments