Сегодня я получил эту ошибку, когда пытался создать базу данных. Ошибка:
15:38:06.690 JDA MainWS-ReadThread JDA ERROR One of the EventListeners had an uncaught exception
java.lang.ExceptionInInitializerError: null
at me.Mesterkender.Listener.getPrefix(Listener.java:55)
at java.util.HashMap.computeIfAbsent(HashMap.java:1127)
at me.Mesterkender.Listener.onGuildMessageReceived(Listener.java:36)
at net.dv8tion.jda.api.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:396)
at net.dv8tion.jda.api.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:96)
at net.dv8tion.jda.internal.hooks.EventManagerProxy.handleInternally(EventManagerProxy.java:82)
at net.dv8tion.jda.internal.hooks.EventManagerProxy.handle(EventManagerProxy.java:69)
at net.dv8tion.jda.internal.JDAImpl.handleEvent(JDAImpl.java:152)
at net.dv8tion.jda.internal.handle.MessageCreateHandler.handleInternally(MessageCreateHandler.java:97)
at net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:36)
at net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:954)
at net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:841)
at net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:819)
at net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:992)
at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:385)
at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:276)
at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:996)
at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:755)
at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108)
at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64)
at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)
Caused by: java.lang.RuntimeException: Failed to get driver instance for jdbcUrl=jdbc:sqlite:database.db
at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:114)
at com.zaxxer.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:320)
at com.zaxxer.hikari.pool.PoolBase.<init>(PoolBase.java:109)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:108)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
at me.Mesterkender.database.SQLiteDataSource.<clinit>(SQLiteDataSource.java:41)
... 21 common frames omitted
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:315)
at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:106)
... 26 common frames omitted
Строки, в которых говорится об ошибке:
private String getPrefix(long guildId) {
try (final PreparedStatement preparedStatement = SQLiteDataSource
// Line 55 Under that text
.getConnection()
// language=SQLite
.prepareStatement("SELECT prefix FROM guild_settings WHERE guild_id = ?")) {
preparedStatement.setString(1, String.valueOf(guildId));
try (final ResultSet resultSet = preparedStatement.executeQuery()) {
if (resultSet.next()) {
return resultSet.getString("prefix");
}
}
Другой:
@Override
public void onGuildMessageReceived(@Nonnull GuildMessageReceivedEvent event) {
User user = event.getAuthor();
if (user.isBot() || event.isWebhookMessage()) {
return;
}
final long guildId = event.getGuild().getIdLong();
// Line 36 Under that text
String prefix = (String) VeryBadDesign.PREFIXES.computeIfAbsent(guildId, this::getPrefix);
String raw = event.getMessage().getContentRaw();
if (raw.equalsIgnoreCase(prefix + "shutdown")
&& user.getId().equals(Config.get("owner_id"))) {
LOGGER.info("Shutting down");
event.getJDA().shutdown();
BotCommons.shutdown(event.getJDA());
return;
}
if (raw.startsWith(prefix)) {
manager.handle(event, prefix);
}
}
И они находятся в моем классе Listener. Я пробовал несколько вещей, но мне это не помогло. Я пытался получить помощь от своего друга, но они тоже не знали решения. Итак, если вы знаете решение, пришлите мне свое предложение. (Я использовал zaxxer и Hikari)