깨진 파일 속성이 UTF-8 로 변경 후 다시 입력/또는 붙여넣는다.
[글쓴이:] 관리자
UncategorizedSQLException 디비 연결 에러
디비 Select 소스에서 다음과 같은 에러시
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
10월 14, 2020 2:20:44 오후 com.test.TEST.action.TESTScAction handleRequest 심각: Error : org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; --- The error occurred in com/test/common/sqlMap/TESTSearch.xml. --- The error occurred while executing query. --- Check the SELECT ...... FROM................ --- Check the SQL Statement (preparation failed). --- Cause: java.sql.SQLException: Cannot create JDBC driver of class '' for connect URL 'null'; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred in com/test/common/sqlMap/TESTSearch.xml. --- The error occurred while executing query. --- Check the SELECT........ FROM................. --- Check the SQL Statement (preparation failed). --- Cause: java.sql.SQLException: Cannot create JDBC driver of class '' for connect URL 'null' |
Server.xml 내용중 HOST 내용에 아래 디비연결 Resource 테그 내용 추가
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log" suffix=".txt"/> <Context docBase="test" path="/" reloadable="true" source="org.eclipse.jst.jee.server:test"> <Resource auth="Container" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" maxActive="50" maxIdle="20" maxWait="10000" name="jdbc/TESTDB" password="**********" testOnBorrow="true" type="javax.sql.DataSource" url="jdbc:sqlserver://***.***.***.****;databaseName=TEST;" username="TESTUSER"/> </Context> </Host> |
참고 : source=”org.eclipse.jst.jee.server:test” 정보 반드시 필요
http://localhost:8080/Directory/
이클립스로 서버를 실행했을 때 다음과 같이 ROOT(/)에서 실행되지 않고 http://localhost:8080/Directory/ 로 나오는 경우 수정 1. Properties ->Web project Settings 2. Server – tomact 를 더블클릭 후 Module 탭 에서 Path / Edit 로 수정
import java.util.map cannot be resolved / jre1.8.0 세팅
Server Tomcat v8.0 Server at localhost failed to start. 소스상에 에러가 있어 수정 후 다시 시작 하면 됩니다. 소스에 에러는 import java.util.map cannot be resolved 이고 Libraries 경로 에러 입니다. Right click on project – >BuildPath – >Configure BuildPath – >Libraries tab – > Double click on JRE SYSTEM LIBRARY – >Then select alternate …
import java.util.map cannot be resolved / jre1.8.0 세팅 더보기
[jsp] 홈페이지 소스 jsp페이지에서 출력
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="java.sql.*,java.net.*,java.io.*,java.lang.*,java.util.*"%> <html> <title></title> <head></head> <body> <% try{ URL oracle = new URL("https://java.ihavenomoney.co.kr/"); BufferedReader in = new BufferedReader( new InputStreamReader(oracle.openStream())); String inputLine; while ((inputLine = in.readLine()) != null) out.println(inputLine); in.close(); }catch(Exception ex){} %> </body> |
[jsp] 디비 연결
|
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import = "java.sql.DriverManager" %> <%@ page import = "java.sql.Connection" %> <%@ page import = "java.sql.PreparedStatement" %> <%@ page import = "java.sql.ResultSet" %> <%@ page import = "java.sql.SQLException" %> <% String connectionURL = "jdbc:mysql://***.***.***.***:3306/IBE?characterEncoding=UTF-8&serverTimezone=UTC"; Connection connection = null; PreparedStatement pstmt = null; ResultSet rs = null; String code = request.getParameter("code"); //Code if(code == null) code=""; String Decode = code; try{ if(code.length()==2){ Class.forName("com.mysql.jdbc.Driver").newInstance(); connection = DriverManager.getConnection(connectionURL, "****user", "*********"); String query ="SELECT airline_code,airline_korean FROM IBE.Airlines where airline_code = ? LIMIT 0, 1"; pstmt = connection.prepareStatement(query); pstmt.setString(1,code); rs = pstmt.executeQuery(); while(rs.next()){ Decode = rs.getString("airline_korean"); } out.println(Decode); }else out.println(code); } catch(Exception ex){ out.println(ex.toString()); }finally{ if(rs != null) try{rs.close();}catch(SQLException ex){} if(pstmt != null) try{pstmt.close();}catch(SQLException ex){} if(connection != null) try{connection.close();}catch(SQLException ex){} } %> |
