Skip to content
This repository was archived by the owner on Jul 9, 2022. It is now read-only.

Throw exception if the DB name contains the quote character #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.sql.Statement;

Expand Down Expand Up @@ -102,6 +103,9 @@ public Connection getConnection() throws SQLException {
protected Connection switchDatabase(Connection con) throws SQLException {
String databaseName = getDatabaseName();
if (databaseName != null) {
if (databaseName.contains(language.quoteChar)) {
throw new IllegalStateException("Database name ["+databaseName+"] contains the quote charecter");
}
Statement s = con.createStatement();
try {
s.execute(language.switchDatabase(databaseName));
Expand Down