나는 (null가 아닌 실행 텍스트 필드에서). 자동으로 텍스트 필드에서 이름을 따 내 응용 프로그램에 대한 데이터베이스를 만들 계획을 가지고 나누었다 내가 같은 다른 자바 페이지에서 동일한 코드 실행을 구문 error.This이 다음 코드는 생성 작업을 수행합니다. 다음데이터베이스 생성
는public void FacltyNameTable(){
String fcltyName = fcltyUserNameTxt.getText();
try{
Class.forName("com.mysql.jdbc.Driver");
conn = (Connection) DriverManager.getConnection(DB_URL_table, USER, PASS);
stmt = (Statement) conn.createStatement();
String sql1 = "CREATE TABLE IF NOT EXISTS '"+fcltyName+"' " +
"(id INTEGER not NULL AUTO_INCREMENT, " +
" rollNo VARCHAR(255), " +
" studentName VARCHAR(255), " +
"CommunicationOral INTEGER, "+
"Communicationwritten INTEGER, "+
"Leadership INTEGER, "+
"AnalyticalAbilities INTEGER, "+
"Interpersonalskills INTEGER, "+
"DecisionMakingSkills INTEGER, "+
"SelfConfidence INTEGER, "+
"Creativity INTEGER, "+
"Punctualityregularity INTEGER, "+
"GeneralAwareness INTEGER, "+
"Commitment INTEGER, "+
"Hardwork INTEGER, "+
" PRIMARY KEY (id))";
stmt.executeUpdate(sql1);
String insert1="INSERT IGNORE INTO '"+fcltyName+"'(id,rollNo,studentName,CommunicationOral,Communicationwritten,Leadership,AnalyticalAbilities,Interpersonalskills,DecisionMakingSkills,SelfConfidence,Creativity,Punctualityregularity,GeneralAwareness,Commitment,HardWork)VALUES(1,'1','ABHIJITH V GEORGE ',0,0,0,0,0,0,0,0,0,0,0,0)";
stmt.executeUpdate(insert1);
}catch(SQLException se){
//Handle errors for JDBC
se.printStackTrace();
}catch(Exception e){
//Handle errors for Class.forName
e.printStackTrace();
}finally{
//finally block used to close resources
try{
if(stmt!=null)
conn.close();
}catch(SQLException se){
}// do nothing
try{
if(conn!=null)
conn.close();
}catch(SQLException se){
se.printStackTrace();
}//end finally try
}//end try
}
오류를
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' (id INTEGER not NULL AUTO_INCREMENT, rollNo VARCHAR(255), studentName VARCH' at line 1
내가 변경 '문자열 SQL1을 보여줍니다 = "NOT이있는 경우 테이블 만들기 "+fcltyName+"' " +........
는 완벽하게 내 쿼리 Wromg.I 도움이 필요
String sql1 = "CREATE TABLE IF NOT EXISTS fcltyName " +.......
에
이 너무 많은 이유가 여기에 세부 사항으로 이동하기위한 정말 좋은 생각입니다! –