Jetty JDBCLoginService using null in mysql request

2019-09-15 05:08发布

问题:

i'm trying to use a JDBCLoginService in Jetty but when it's used by my app i get this error in the logs:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null where null = 'admin'' at line 1

like if jetty wasn't using the columns in the properties file

the jetty.xml part:

<Call name="addBean">
  <Arg> 
    <New class="org.eclipse.jetty.security.JDBCLoginService">
      <Set name="name">gateway_jndi</Set>
      <Set name="config">/usr/local/jetty/etc/jdbcRealm.properties</Set>
    </New>
 </Arg>
</Call>

/usr/local/jetty/etc/jdbcRealm.properties has been chmoded to 777 and seems to be used since with a wrong path i get an error.

jdbcRealm.properties content:

jdbcdriver = org.gjt.mm.mysql.Driver
url = jdbc:mysql://mydatabasefqdb:3306/mydatabasename
username = mydatabaseuser
password = mydatabasepassword
userTable = gateway_users
userTableKey = ID
userTableUserField = USERNAME
userTablePasswordField = PASSWORD
roleTable = gateway_roles
roleTableKey = ID
roleTableRoleField = NAME
userRoleTableName = gateway_users_roles
userRoleTableUserKey = user_id
userRoleTableRoleKey = role_id
cachetime = 300

versions:

jetty: 9.3.2

jre: 8

mysql: 5.5

回答1:

it was the caps in the properties file...

with this one it work:

jdbcdriver = org.gjt.mm.mysql.Driver
url = jdbc:mysql://mydatabasefqdn:3306/mydatabasename
username = mydatabaseuser
password = mydatabasepassword
usertable = gateway_users
usertablekey = ID
usertableuserfield = USERNAME
usertablepasswordfield = PASSWORD
roletable = gateway_roles
roletablekey = ID
roletablerolefield = NAME
userroletable = gateway_users_roles
userroletableuserkey = user_id
userroletablerolekey = role_id
cachetime = 300


标签: java mysql Jetty