package db;
import java.util.*
import java.sql.*;
public class jdbcUtil {
static{
try{
//Class.forName("oracle.jdbc.driver.OracleDriver");
class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
}
public static Connection getConnection(){
Connection con = null;
try{
//con = DriverManager.getConnection("jdbc:oracle:thin:@172.16.201.1:1521:orcl","java1","java1");
con = DriverManager.getConnection("jdbc:mysql:thin:@localhost:3306:java","java","java");
con.setAutoCommit(false);
}
catch(Exception e){
e.printStackTrace();
}
return con;
}
public static void close(Connection con){
try{
con.close();
}
catch(Exception e){
}
}
public static void close(Statement stmt){
try{
stmt.close();
}
catch(Exception e){
}
}
public static void close(ResultSet rs){
try{
rs.close();
}
catch(Exception e){
}
}
public static void commit(Connection con)
{
try{
con.commit();
System.out.println("commit success");
}
catch(Exception e){
System.out.println("commit fail");
}
}
public static void rollback(Connection con)
{
try{
con.rollback();
System.out.println("rollback success");
}
catch(Exception e){
System.out.println("rollback fail");
}
}
}
package db;
import java.util.*
import java.sql.*;
public class jdbcUtil {
static{
try{
//Class.forName("oracle.jdbc.driver.OracleDriver");
class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
}
public static Connection getConnection(){
Connection con = null;
try{
//con = DriverManager.getConnection("jdbc:oracle:thin:@172.16.201.1:1521:orcl","java1","java1");
con = DriverManager.getConnection("jdbc:mysql:thin:@localhost:3306:java","java","java");
con.setAutoCommit(false);
}
catch(Exception e){
e.printStackTrace();
}
return con;
}
public static void close(Connection con){
try{
con.close();
}
catch(Exception e){
}
}
public static void close(Statement stmt){
try{
stmt.close();
}
catch(Exception e){
}
}
public static void close(ResultSet rs){
try{
rs.close();
}
catch(Exception e){
}
}
public static void commit(Connection con)
{
try{
con.commit();
System.out.println("commit success");
}
catch(Exception e){
System.out.println("commit fail");
}
}
public static void rollback(Connection con)
{
try{
con.rollback();
System.out.println("rollback success");
}
catch(Exception e){
System.out.println("rollback fail");
}
}
}
package db;
import java.util.*
import java.sql.*;
public class jdbcUtil {
static{
try{
//Class.forName("oracle.jdbc.driver.OracleDriver");
class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
}
public static Connection getConnection(){
Connection con = null;
try{
//con = DriverManager.getConnection("jdbc:oracle:thin:@172.16.201.1:1521:orcl","java1","java1");
con = DriverManager.getConnection("jdbc:mysql:thin:@localhost:3306:java","java","java");
con.setAutoCommit(false);
}
catch(Exception e){
e.printStackTrace();
}
return con;
}
public static void close(Connection con){
try{
con.close();
}
catch(Exception e){
}
}
public static void close(Statement stmt){
try{
stmt.close();
}
catch(Exception e){
}
}
public static void close(ResultSet rs){
try{
rs.close();
}
catch(Exception e){
}
}
public static void commit(Connection con)
{
try{
con.commit();
System.out.println("commit success");
}
catch(Exception e){
System.out.println("commit fail");
}
}
public static void rollback(Connection con)
{
try{
con.rollback();
System.out.println("rollback success");
}
catch(Exception e){
System.out.println("rollback fail");
}
}
}
학원에서 배운내용인데. 이페이지는 DB를 연결하는 페이지건 아는데 지금 주석처리한 부분이 학원에서 oracle로 연동한 부분입니다. 제가 주석 처리한것이고요..
mysql로 jsp - Data Source Explorer 부분에 연동은 했습니다. 그런데 위에 빨간색처리한부분과 동일한 String에 모두 에러가뜹니다.
학원의 환경에 있던거 다른 환경으로 그냥 import하니까 에러가 뜨는 건 이해하겠는데 이부분은 어떻게 해야하는지 전혀 모르겠어요..
제발 알려주세요. |