com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'username_id' cannot be null

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Samebug tips

,

Check whether privilege has the "not null" restriction. If so it always has to have a value and can never be null.

A different reason could be a wrong implementation of a foreign key. Check whether you always correctly insert/update in both tables.

,

Nothing is wrong with the database. When it gives you those errors, it's telling you that you are trying to input "nothing" (null) into a column that doesn't allow it. Fix it by removing the not null constraint or by passing a value to that field.

Solutions on the web

via GitHub by viet
, 1 year ago
Column 'username_id' cannot be null
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'username_id' cannot be null
at sun.reflect.GeneratedConstructorAccessor150.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.Util.getInstance(Util.java:387)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:934)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3870)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3806)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2470)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2617)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2550)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2073)
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2009)
at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5094)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1994)
at com.greatmancode.com.zaxxer.libs.hikari.proxy.PreparedStatementProxy.executeUpdate(PreparedStatementProxy.java:61)
at com.greatmancode.com.zaxxer.libs.hikari.proxy.PreparedStatementJavassistProxy.executeUpdate(PreparedStatementJavassistProxy.java)
at com.greatmancode.craftconomy3.storage.sql.SQLStorageEngine.getAccount(SQLStorageEngine.java:114)
at com.greatmancode.craftconomy3.storage.StorageEngine.getAccount(StorageEngine.java:54)
at com.greatmancode.craftconomy3.account.AccountManager.getAccount(AccountManager.java:54)
at com.greatmancode.craftconomy3.events.EventManager.playerJoinEvent(EventManager.java:54)
at sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.greatmancode.craftconomy3.tools.events.ListenerRegistration.callEvent(ListenerRegistration.java:40)
at com.greatmancode.craftconomy3.tools.events.EventManager.callEvent(EventManager.java:66)
at com.greatmancode.craftconomy3.tools.events.bukkit.PlayerJoinEventListener.onPlayerJoin(PlayerJoinEventListener.java:32)
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor59.execute(Unknown Source)
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78)
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:517)
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:502)
at net.minecraft.server.v1_10_R1.PlayerList.onPlayerJoin(PlayerList.java:356)
at net.minecraft.server.v1_10_R1.PlayerList.a(PlayerList.java:175)
at net.minecraft.server.v1_10_R1.LoginListener.b(LoginListener.java:144)
at net.minecraft.server.v1_10_R1.LoginListener.E_(LoginListener.java:54)
at net.minecraft.server.v1_10_R1.NetworkManager.a(NetworkManager.java:233)
at net.minecraft.server.v1_10_R1.ServerConnection.c(ServerConnection.java:152)
at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:886)
at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:404)
at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:725)
at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:624)
at java.lang.Thread.run(Thread.java:745)

Users with the same issue

You are the first who have seen this exception.

Write tip

Know the solutions? Share your knowledge to help other developers to debug faster.