Created
July 26, 2018 08:33
-
-
Save XDean/05bb12fae9f6e70266017ef7112488c1 to your computer and use it in GitHub Desktop.
init DriverManager.logWriter. Question 51533343 on stackoverflow.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyDriver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.PrintWriter; | |
import java.sql.Connection; | |
import java.sql.Driver; | |
import java.sql.DriverManager; | |
import java.sql.DriverPropertyInfo; | |
import java.sql.SQLException; | |
import java.sql.SQLFeatureNotSupportedException; | |
import java.util.Properties; | |
import java.util.logging.Logger; | |
public class MyDriver implements Driver { | |
static { | |
DriverManager.setLogWriter(new PrintWriter(System.out)); | |
} | |
@Override | |
public Connection connect(String url, Properties info) throws SQLException { | |
return null; | |
} | |
@Override | |
public boolean acceptsURL(String url) throws SQLException { | |
return false; | |
} | |
@Override | |
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { | |
return null; | |
} | |
@Override | |
public int getMajorVersion() { | |
return 0; | |
} | |
@Override | |
public int getMinorVersion() { | |
return 0; | |
} | |
@Override | |
public boolean jdbcCompliant() { | |
return false; | |
} | |
@Override | |
public Logger getParentLogger() throws SQLFeatureNotSupportedException { | |
return null; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.sql.DriverManager; | |
public class UseDriver { | |
public static void main(String[] args) { | |
DriverManager.getDrivers(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
File structrue
Run
You will get