package com.demo.user;
import java.sql.Connection;
import java.sql.DriverManager;
public class DbUtil {
public static Connection getConnection(){
Connection conn=null;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc:oracle:thin:@localhost:1521:orcl";
String username="orcl";
String password="password";
//DriverManager.getConnection(url, username, password);
conn=DriverManager.getConnection(url, username, password);
}
catch (ClassNotFoundException e){
e.printStackTrace();
}
return conn;
}
public static void main(String [] args){
DbUtil.getConnection();
}
}
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Unhandled exception type SQLException
at com.demo.user.DbUtil.getConnection(DbUtil.java:14)
at com.demo.user.DbUtil.main(DbUtil.java:22)