我使用的getGeneratedKeys()直接調用類像這樣:的getGeneratedKeys()不使用JNDI在WildFly工作與火鳥
public static Connection getConnection() throws Exception {
try {
Class.forName("org.firebirdsql.jdbc.FBDriver");
String sql = "jdbc:firebirdsql:localhost/3050:e:\\COMPLEXO140116.FDB?defaultResultSetHoldable=True&encoding=WIN1252";
return DriverManager.getConnection(sql, "SYSDBA", "masterkey");
} catch (ClassNotFoundException e) {
throw new SQLException("Driver nao localizado.");
} catch (Exception e) {
e.printStackTrace();
throw new Exception("Erro na base de dados." + e.getMessage() + " fim msg");
}
}
和它工作正常,但之後我改變
public class ConnectionFactory {
private static DataSource dataSource;
static {
try {
dataSource = (DataSource) new InitialContext().lookup("java:jboss/Firebird");
} catch (NamingException e) {
throw new ExceptionInInitializerError("'jndifordbconc' not found in JNDI");
}
}
public static Connection getConnection() throws SQLException {
return dataSource.getConnection();
}
}
它停止工作給予錯誤:
org.firebirdsql.jdbc.FBDriverNotCapableException: Generated keys functionality not available, most likely cause: ANTLR-Runtime not available on classpath
我使用WildFly 10,火鳥2.5.5,Jaybird 2 .2.9。 antlr-4.5.2-complete.jar存在於構建路徑中,可能這不是原因,因爲它在更改爲JNDI方式之前正在工作。野蠅攜帶它自己的antlr 2.7.7。
是的,它解決了我的問題。 – erickdeoliveiraleal
@erickdeoliveiraleal如果我將編輯移動到問題的答案中,是否有任何異議? –
不,任何異議。 – erickdeoliveiraleal