-
-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for custom JdbcCustomization via Spring Boot #357
Changes from 1 commit
b3e3282
9f4b26f
ba9cf4f
0d9da00
31496fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (C) Gustav Karlsson | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.github.kagkarlsson.scheduler.jdbc; | ||
|
||
import java.io.IOException; | ||
import java.io.Reader; | ||
import java.nio.charset.StandardCharsets; | ||
import java.sql.Clob; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
|
||
public class MssqlJtdsJdbcCustomization extends MssqlJdbcCustomization { | ||
|
||
@Override | ||
public String getName() { | ||
return "MSSQL-jTDS"; | ||
} | ||
|
||
@Override | ||
public byte[] getBytes(ResultSet rs, String columnName) throws SQLException { | ||
byte[] result; | ||
try (Reader reader = ((Clob) rs.getObject(columnName)).getCharacterStream()) { | ||
char[] charArray = new char[8 * 1024]; | ||
StringBuilder builder = new StringBuilder(); | ||
int numCharsRead; | ||
while ((numCharsRead = reader.read(charArray, 0, charArray.length)) != -1) { | ||
builder.append(charArray, 0, numCharsRead); | ||
} | ||
result = builder.toString().getBytes(StandardCharsets.UTF_16LE); | ||
} catch (IOException e) { | ||
throw new SQLException(e); | ||
} | ||
return result; | ||
} | ||
} | ||
kagkarlsson marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,8 @@ public class CronSchedule implements Schedule, Serializable { | |
|
||
private static final String DISABLED = "-"; | ||
private static final Logger LOG = LoggerFactory.getLogger(CronSchedule.class); | ||
|
||
private static final long serialVersionUID = 6577185347687546367L; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why, but I receive InvalidClassException, if this ID is missing and database entry was created with master version. I used the same JVM for compiling master and this branch, but still the error occurs - not sure why.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, that's a bit strange. When I think about it, I suppose the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you need to investigate that a bit more. We cannot add that without reason since it might break serialization for other users. That said, it should really have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was a mistake on my part not setting a value for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was a mistake on my part not setting a value for |
||
private final String pattern; | ||
private final ZoneId zoneId; | ||
private transient ExecutionTime cronExecutionTime; // lazily initialized | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff moving the
getBytes(..)
into the Customization