Skip to content

Commit 8c1e4fa

Browse files
authored
feat: Inline micro jdbc (#682)
Rather than maintaining it as a separate project, inline it to simplify both maintenance and understanding.
1 parent eda01aa commit 8c1e4fa

25 files changed

+1449
-24
lines changed

db-scheduler/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@
8080
<version>${slf4j.version}</version>
8181
</dependency>
8282
<!-- Shaded -->
83-
<dependency>
84-
<groupId>com.github.kagkarlsson</groupId>
85-
<artifactId>micro-jdbc</artifactId>
86-
<version>${micro-jdbc.version}</version>
87-
</dependency>
8883
<dependency>
8984
<groupId>com.cronutils</groupId>
9085
<artifactId>cron-utils</artifactId>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (C) Gustav Karlsson
3+
*
4+
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5+
* except in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* <p>http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
10+
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
* express or implied. See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package com.github.kagkarlsson.jdbc;
15+
16+
import java.sql.PreparedStatement;
17+
import java.sql.SQLException;
18+
19+
public interface BatchPreparedStatementSetter<U> {
20+
21+
void setParametersForRow(U value, PreparedStatement preparedStatement) throws SQLException;
22+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (C) Gustav Karlsson
3+
*
4+
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5+
* except in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* <p>http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
10+
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
* express or implied. See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package com.github.kagkarlsson.jdbc;
15+
16+
import java.sql.Connection;
17+
import java.sql.SQLException;
18+
19+
public interface ConnectionSupplier {
20+
Connection getConnection() throws SQLException;
21+
22+
boolean commitWhenAutocommitDisabled();
23+
24+
boolean isExternallyManagedConnection();
25+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (C) Gustav Karlsson
3+
*
4+
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5+
* except in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* <p>http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
10+
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
* express or implied. See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package com.github.kagkarlsson.jdbc;
15+
16+
import java.sql.Connection;
17+
import java.sql.SQLException;
18+
import javax.sql.DataSource;
19+
20+
public class DataSourceConnectionSupplier implements ConnectionSupplier {
21+
private DataSource dataSource;
22+
private boolean commitWhenAutocommitDisabled;
23+
24+
public DataSourceConnectionSupplier(DataSource dataSource, boolean commitWhenAutocommitDisabled) {
25+
this.dataSource = dataSource;
26+
this.commitWhenAutocommitDisabled = commitWhenAutocommitDisabled;
27+
}
28+
29+
@Override
30+
public Connection getConnection() throws SQLException {
31+
return dataSource.getConnection();
32+
}
33+
34+
@Override
35+
public boolean commitWhenAutocommitDisabled() {
36+
return commitWhenAutocommitDisabled;
37+
}
38+
39+
@Override
40+
public boolean isExternallyManagedConnection() {
41+
return false;
42+
}
43+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (C) Gustav Karlsson
3+
*
4+
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5+
* except in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* <p>http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
10+
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
* express or implied. See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package com.github.kagkarlsson.jdbc;
15+
16+
import java.sql.Connection;
17+
18+
public interface DoInTransaction<T> {
19+
T doInTransaction(Connection c);
20+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (C) Gustav Karlsson
3+
*
4+
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5+
* except in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* <p>http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
10+
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
* express or implied. See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package com.github.kagkarlsson.jdbc;
15+
16+
import java.sql.Connection;
17+
18+
public class ExternallyManagedConnection implements ConnectionSupplier {
19+
20+
private final Connection externallyManagedConnection;
21+
22+
public ExternallyManagedConnection(Connection externallyManagedConnection) {
23+
this.externallyManagedConnection = externallyManagedConnection;
24+
}
25+
26+
@Override
27+
public Connection getConnection() {
28+
return externallyManagedConnection;
29+
}
30+
31+
@Override
32+
public boolean commitWhenAutocommitDisabled() {
33+
return false;
34+
}
35+
36+
@Override
37+
public boolean isExternallyManagedConnection() {
38+
return true;
39+
}
40+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (C) Gustav Karlsson
3+
*
4+
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5+
* except in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* <p>http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
10+
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
* express or implied. See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package com.github.kagkarlsson.jdbc;
15+
16+
import java.sql.SQLException;
17+
18+
public class IntegrityConstraintViolation extends SQLRuntimeException {
19+
public IntegrityConstraintViolation(SQLException ex) {
20+
super(ex);
21+
}
22+
}

0 commit comments

Comments
 (0)