스프링

 

public class MySQLConnectionTest {

	private static final String DRIVER ="com.mysql.jdbc.Driver";
	private static final String URL ="jdbc:mysql://localhost:3305/hamansuk?characterEncoding=utf8";
	private static final String USER = "1111";
	private static final String PW = "1111" ;

	private static final Logger logger =LoggerFactory.getLogger(MySQLConnectionTest.class);
	
	
	@Test
	public void testConnection() throws Exception{
		
		Class.forName(DRIVER);
		try(Connection  con =DriverManager.getConnection(URL, USER, PW)){
			
			System.out.println(con);
			//logger.info(con);
		}catch(Exception e){
			
		}
		
		
	}
	
	
}

 

public class OracleConnectionTest {

	private static final String DRIVER ="oracle.jdbc.driver.OracleDriver";
	private static final String URL ="jdbc:oracle:thin:@localhost:1521:xe";
	private static final String USER = "spring";
	private static final String PW = "1234" ;

	@Test
	public void testConnection() throws Exception{
		
		Class.forName(DRIVER);
		try(Connection  con =DriverManager.getConnection(URL, USER, PW)){
			
			System.out.println(con);
			
		
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
}

 


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"file:src/main/webapp/WEB-INF/spring/**/*.xml"})
public class MyBatisTest {

	@Inject
	private SqlSession sqlSession;
	
	@Inject
	private SqlSessionFactory factory;
	
	@Inject
	private DataSource ds;
	
	private static final Logger logger=LoggerFactory.getLogger(MyBatisTest.class);
	
	@Test
	public void testDataSource(){
		try(Connection con =ds.getConnection()){
			
			logger.info("DataSource : " +con);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	
	@Test
	public void testFactory(){
		logger.info( " SqlSessionFactory  : " +factory.toString());
	}
	
	
	//@Test
	public void mysqlTestSession() throws Exception {
	
		try (SqlSession session =factory.openSession()){
			logger.info("***********************MySQL************************");			
			logger.info( " sqlSession : " +sqlSession.toString());

			logger.info( " factory.openSession() : " +session.toString());
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	
	
	@Test
	public void oralceTestSession() throws Exception {
	
		try (SqlSession session =factory.openSession()){
			logger.info("***********************ORACLE************************");			
			logger.info( " sqlSession : " +sqlSession.toString());

			logger.info( " factory.openSession() : " +session.toString());
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	
	
	
}

 

spring

 

about author

PHRASE

Level 60  머나먼나라

아름다운 의복보다는 웃는 얼굴이 훨씬 인상적이다. 기분 나쁜 일이 있더라도 웃음으로 넘겨보라. 찡그린 얼굴을 펴기만 해도 마음이 한결 편해질 것이다. 웃는 얼굴은 좋은 화장일 뿐 아니라 피의 순환을 좋게 하는 효과가 있다. 웃음은 인생의 약이다. -알랭

댓글 ( 4)

댓글 남기기

작성

스프링 목록    more