티스토리 뷰

반응형

11년 8월 기준.

 

package talktab.db;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;

import java.sql.Statement;

public class dbtest {

public static boolean dbtest(){

Connection conn;

Statement stmt;

 

try{

Class.forName("com.mysql.jdbc.Driver");

 

}catch(ClassNotFoundException e){

System.err.print("ClassNotFoundException: ");

return false;

}

 

try{

String url="jdbc:mysql://192.168.0.100:3306/talktab";

String id="mysql";

String pass="mysql";

conn = DriverManager.getConnection(url,id,pass);

stmt=conn.createStatement();

 

stmt.close();

conn.close();

 

System.out.println("connect");

 

}catch(SQLException e){

System.out.println("SQLException: "+e.getMessage());

return false;

}

return true;

}

 

}

반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/12   »
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
글 보관함