Я пытаюсь использовать javax.sql.DataSource впрыскивается в сервлет (GlassFish)java.sql.SQLException: Доступ запрещен для пользователя 'userapp' @ 'локальный'/GlassFish
@Resource (name="jdbc/MysqlDS")
javax.sql.DataSource mysqlDS;
Следующая заявления терпят неудачу, бросая "java.sql.SQLException: Доступ запрещен для пользователя 'userapp' @ 'локальный' (используя пароль: ДА)":
con=mysqlDS.getConnection();
PreparedStatement pstmt=con.prepareStatement("select now()");
или
con=mysqlDS.getConnection("userapp","userpassword");
PreparedStatement pstmt=con.prepareStatement("select now()");
но следующие были успешными:
Class.forName("com.mysql.jdbc.Driver");
con = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/user_lindenb", "appuser", "userpassword");
w.println("OK");
con.close(); con=null;
или
con=mysqlDS.getConnection("root","root_password");
или
con=mysqlDS.getConnection("me","mypassword");
или
$ mysql -u appuser --password=userpassword -D user_lindenb -e 'select now()'
+---------------------+
| now() |
+---------------------+
| 2015-08-05 10:19:07 |
+---------------------+
Грант d eclared следующим образом:
grant insert,select,update,delete on user_lindenb.* TO 'appuser'@'localhost' identified by 'userpassword';
и ресурсы были объявлены как следовать
asadmin --port 8138 create-jdbc-connection-pool \
--datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource \
--restype javax.sql.DataSource \
--property "password=userpassword:user=userapp:serverName=localhost:databaseName=user_lindenb" \
MysqlDS
asadmin --port 8138 create-jdbc-resource \
--connectionpoolid MysqlDS \
"jdbc/MysqlDS"
, что случилось с этим пользователем "userapp?
спасибо.