Getting this error in run the hybrisserver - java

log4j:ERROR Could not connect to remote log4j server at [localhost]. We will try again later.
ERROR [WrapperSimpleAppMain] [DataSourceImpl] error connecting to DataSource having url jdbc:mysql://localhost/monsoon_qa?useConfigs=maxPerformance&characterEncoding=utf8: Access denied for user 'monsoon'#'localhost' to database 'monsoon_qa'
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user 'monsoon'#'localhost' to database 'monsoon_qa'

looks like you have forgotten to grant the appropriate rights (or not created the user at all?) that is configured to connect hybris to mysql.
You have to create it somehow like this:
create database dbName CHARACTER SET utf8 COLLATE utf8_bin;
create user 'theUser'#'localhost' identified by 'thePassword';
grant all privileges on dbName.* to 'theUser'#'localhost';
in your local.properties file you need to add an appropriate mysql configuration, something like this:
db.url=jdbc:mysql://localhost/dbName?useConfigs=maxPerformance&characterEncoding=utf8&innodb_flush_log_at_trx_commit=0
db.driver=com.mysql.jdbc.Driver
db.username=theUser
db.password=thePassword
Hope that helps.
Note that this is just example information. If you want to setup your hybris for a production system you might have to do a few more things, but for a development setup this should get you started.

i got the same problem. The solution is initialize database. Run the following command
sudo service mysql start
if this command doesn't work run it again and run the following command(for control)
sudo service mysql status

Related

Error when trying to connect to H2 database

Did any of you had this below error when trying to connect to H2?
The release I'm using is 1.4.199, on windows, with TAFJFuctions.
First I run this command:
java -server -cp h2-1.4.199.jar;C:\Users\...\H2\TAFJFunctions.jar org.h2.tools.Server -web -tcp -tcpPort 9092 -tcpAllowOthers -baseDir C:\Users\...\H2\bin
and I've got connected with TCP server running and Web Console server running as well.
Then I've run this command:
SET H2URL=jdbc:h2:tcp://locaLhost/t24db;DB_CLOSE_ON_EXIT=FALSE;MODE=Oracle;TRACE_LEVEL_FILE=0;TRACE_LEVEL_SYSTEM_OUT=0;FILE_LOCK=NO;IFEXISTS=TRUE;CACHE_SIZE=8192;MVCC=TRUE;LOCK_TIMEOUT=60000
And then this command:
java -server -cp h2-1.4.199.jar;C:\Users\...\H2\TAFJFunctions.jar org.h2.tools.Shell -url %H2URL% -driver org.h2.Driver -user t24 -password t24
And here I've got the below error:
"Exception in thread "main" org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database "C:/Users/.../H2/bin/t24db" not found, and IFEXISTS=true, so we cant auto-create it [90146-199]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:617)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:427)
at org.h2.message.DbException.get(DbException.java:205)
at org.h2.message.DbException.get(DbException.java:181)
at org.h2.engine.Engine.openSession(Engine.java:67)
at org.h2.engine.Engine.openSession(Engine.java:201)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:178)
at org.h2.engine.Engine.createSession(Engine.java:161)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:160)
at java.lang.Thread.run(Unknown Source)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:617)
at org.h2.engine.SessionRemote.done(SessionRemote.java:607)
at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:143)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:431)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:317)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:169)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:148)
at org.h2.Driver.connect(Driver.java:69)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.h2.tools.Shell.runTool(Shell.java:148)
at org.h2.tools.Shell.main(Shell.java:81)"
Any idea how to get this working?
Thank you,
Carina
With IFEXISTS=TRUE the problem is oblivious, but without this parameter or with attempt to set it to FALSE situation is not going to be changed.
All recent versions of H2 database don't allow remote (including local TCP connections) database creation by default any more due to security reasons. When it is allowed, everyone who can connect to your port can create a new database, get ADMIN privileges in it and therefore get the same access to your system as your JVM and your user account allows.
Unfortunately, H2 1.4.199 throws a confusing error message, it was improved only in 1.4.200 and in this version (when IFEXISTS=TRUE wasn't used) the error message is “Database … not found, either pre-create it or allow remote database creation (not recommended in secure environments)”.
If you use a TCP (or Pg/ODBC) server you need to create your databases in some other way before you try to connect to them with networked protocol.
For example, you can open the JDBC connection (DriverManager.getConnection()) with embedded URL and close it immediately.
You can replace org.h2.tools.Server with org.h2.tools.Console and you'll see another http connection URL (if you start it from the command line), something like http://127.0.0.2:8082?key=12c58e1c5f9ce1ae88a2921f74e7655ed91a80746730cc6bfa8d4bbb464f69ee; with this URL you will be able to create the database from the web interface (only if remove web interface is not enabled).
You can also add the -tool parameter (only to Console, the Server doesn't support it) to get H2 Console icon in the system tray, its context menu has a command to create a new database and this icon can also open the web interface with the same security key. Don't share this key with anyone. It will be different on each restart, however.
You can also use the command-line Shell tool.
https://h2database.com/html/tutorial.html#creating_new_databases
In the worst case you can enable the remove database creation, but it is not really secure even with local connections and it is completely insecure when remote connections are enabled as in your case. You will have a well-known remote security hole in your system, I don't think that it is your intention.
The problem here is that there is no database called t24db already.
In the property spring.datasource.url property which you use to connect to h2, remove the parameter IFEXISTS=TRUE.
This will ensure that the database is created if it does not exist.

Changing Hadoop Username during runtime doesn't work

I wrote a little Hadoop Client Java application, that lists all files in HDFS (unsecure) and all tables in Hive, and some more stuff. However, I need to change the Hadoop Username during runtime.
Setting the name via System.setProperty("HADOOP_USER_NAME", "testuser"); works fine for the first time I need this username. But when I want to change the username to e.g. System.setProperty("HADOOP_USER_NAME", "hdfs"); I get an exception (after setting the hadoop username to hdfs as shown above):
org.apache.hadoop.security.AccessControlException: Permission denied: user=testuser, access=READ_EXECUTE, inode="/app-logs/ambari-qa":ambari-qa:hadoop:drwxrwx---
What could be the problem here? Why can't I just change the username via the HADOOP_USER_NAME property whenever I want to?
EDIT
Can I just use UserGroupInformation.setLoginUser(UserGroupInformation.createRemoteUser(username)); to change the user during runtime or are there some restrictions?
Because, you are connecting to HDFS or Hive using JDBC connection.
Till you close the existing connection , you cannot make one more connection from the same application to HDFS/Hive service .

Yet another "Access denied for user" error..but I can log in directly to remote server from command line

Java 1.7
Spring 3.1.1 with Spring-WS 2.1.1
Joda
Hibernate 3.6
MySQL 5.0.51a
Maven 3
Tomcat 7
Eclipse 3.7
Greetings all...
Just another 'Access denied for user 'foo'#'localhost' error being thrown by my webapp, but with a twist.
I run both an instance of MySQL on my (duh) local machine for development, and another on my remote server.
Both instances have a database 'mydb' and two tables with identical names and structures.
On the local instance I use root.
On the remote machine I have issued the following sequence:
CREATE USER 'fubar'#'localhost' IDENTIFIED BY 'mypwd';
CREATE USER 'fubar'#'%' IDENTIFIED BY 'mypwd';
CREATE USER 'fubar'#'my.remote.server.com' IDENTIFIED BY 'mypwd';
GRANT ALL ON mydb.* TO ' CREATE USER 'fubar'#'localhost' IDENTIFIED BY 'mypwd';
GRANT ALL ON mydb.* TO ' CREATE USER 'fubar'#'%' IDENTIFIED BY 'mypwd';
GRANT ALL ON mydb.* TO ' CREATE USER 'fubar'#'my.remote.server.com' IDENTIFIED BY 'mypwd';
FLUSH PRIVILEGES;
I've confirmed with a 'select * from mysql.db' that three new rows appear and that all the appropriate fields have 'Y' values.
On the local machine from within a Command Prompt pane I can issue:
mysql -u fubar -p -h my.remote.server.com ,
reply with the password and get connected to the remote db.
Executing my java program fails with the famous
'Access denied for user 'fubar'#'localhost'
when url is adjusted to point to remote server
Using the following as part of my db.properties file in my Eclipse project:
hibernate.connection.url=jdbc:mysql://localhost:3306/mydb
hibernate.connection.username=root
hibernate.connection.password=myrootpwd
execution works great
execution fails with the dreaded error when using this:
hibernate.connection.url=jdbc:mysql://my.remote.servier.com:3306/mydb
hibernate.connection.username=fubar
hibernate.connection.password=mypwd
So I am stumped. How is that I can connect directly to the remote instance of MySQL server using the command line but not in my db.properties file?
TIA,
Still-learning Stev
I got into the same issue and its the wrong password that created the whole issue...
You can use the standalone java program code in the below link to test your connection and make sure it works first...
http://www.mkyong.com/jdbc/how-to-connect-to-mysql-with-jdbc-driver-java/

Access denied for user 'root'#'localhost' (using password: YES)

Hi I'm working on a Liferay portlet that accesses the database using JPA. I'm using Tomcat 7 and MySQL.
This portlet works fine in my machine but when I move the portlet to a test environment in another server and try to use it in the test portal I get the following error:
Access denied for user 'root'#'localhost' (using password: YES)
The database connection database in my persistence.xml is ok.
I tried putting wrong connection data in the persistence.xml to see if the error changed but it didn't. For example I set the user as "wronguser" and when I deployed the portlet and tried to use it again I got exactly the same error:
Access denied for user 'root'#'localhost' (using password: YES)
Even if I change the database name or URL the error is always the same. It's like something is not getting updated. I tried deleting the Tomcat temp folder but didn't help.
Any ideas?
Thanks in advance.
I tried putting wrong connection data in the persistence.xml to see if
the error changed but it didn't. For example I set the user as
"wronguser" and when I deployed the portlet and tried to use it again
I got exactly the same error:
This just shows that the username/password given to mysql at the end is not coming from your configuration file as expected, but from to-be-identified-elsewhere.
Until you see mysql complaining about "wronguser" not being able to connect, this is the first roadblock to clear, and the problem is most likely in the application setup, not in mysql.
Should the mysql server complain later about privileges for "wronguser", then sure, the area to investigate then will be grants for this user, but you need to convey the proper user/host/password information to the server first.

HSQLDB server mode username/password

If I start the HSQLDB in server mode using my Java code, the server starts without any problem. However, when I try to connect to the same either through the Java code or through the HSQLDB DatabaseManagerSwing; I am unable to connect.
I started the server with user=conn1 and password=conn1 in memory-only mode. But when connecting to the server it gave me following exception:
java.sql.SQLInvalidAuthorizationSpecException: invalid authorization specification - not found: conn1
I can only connect by giving user=SA and blank password. I am using HSQLDB 2.2.5 and JRE1.7 on Windows7 machine.
Can someone tell me where am I doing wrong?
If you try these server properties with recent versions of HyperSQL, you will probably get an error message as your server properties are not correct. The properties "server.username" and "server.password" are not valid. And the dbname.0 property must be in lowercase.
If you want to create a server database with a user name other than SA, you can append the user and password to the database path:
server.database.0 = file:E:/DB/myDB;user=testuser;password=testpw
server.dbname.0 = mydb
After the server is shutdown, there is no need to include the user and password. The credentials are used only to create the database. After that, the credentials are checked when a connection is made to the server.
2020 update with additional information due to recent questions in comments:
The user name and password specified for database.0 are taken into account only when a new database is created by starting the server. If the database files exist before starting the server, user name and password are unnecessary and are simply ignored.
Other settings for a new database, such as hsqldb.tx=mvcc, can be appended to the database.0 string.
You must have properties for database.0 for your server. You can add properties for database.1 if your server is serving two different databases.
The file path specified for database.0 is hidden from the users that connect to the server. Only the dbname.0 value is used for access, for example:
DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/mydb;uer=testuser;password=testpw")
In the getConnection call, it is better to state the user and password separately to keep the code clear:DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/mydb", "testuser", "testpw")
See the Guide http://hsqldb.org/doc/2.0/guide/dbproperties-chapt.html for all the details.
Appears the problem you were running into (at least initially) is that, for HSQL in memory databases, if it's the "first" in memory database (i.e. process just started), the username "has to be" sa (username "sa" is not case sensitive, or it can be empty username, which implies the "default" which is also sa). You can use a blank password, or specify a password. Based on some trial and error, if you want to reconnect to the same (in memory) DB later, you'll have to re-use the same password (blank or otherwise). If you want to use a user other than SA you'd probably have to first connect to your database using SA and execute some "create user" type commands to create new users. Then reconnect using that user (assuming your DB is all in memory).
You can use multiple different in-memory databases (if that's what you're trying to accomplish by specifying a different user) like this:
// change the MySpecialTestDb String for multiple different in memory databases
// or reuse the same value
// to reconnect to a previously created in memory database [i.e. within the same process previously].
String DB_CONNECTION_STR = "jdbc:hsqldb:mem:MySpecialTestDb";
String DB_USERNAME_STR = "sa";
String DB_USERNAME_PASSWORD = "";
DriverManager.getConnection(DB_CONNECTION_STR, DB_USERNAME_STR, DB_USERNAME_PASSWORD);
Each new database you create follows the same system (it must be initial user SA and "adopts" whatever first password you give).
ref: http://www.hsqldb.org/doc/1.8/guide/guide.html#advanced-chapter
Or if you want to just "reset" an in memory database, like between each unit test, see here.
Note that documentation also says "...This feature [default user SA] has a side effect that can confuse new users. If a mistake is made in specifying the path for connecting to an existing database, a connection is nevertheless established to a new database. For troubleshooting purposes, you can specify a connection property ifexists=true ..."
Point no 1) Whenever you create a DB, you have to specify the username and password. You can keep it both blank; But same username and password has to be used while connecting to server.
If you observe script file of your DB, you can see commands like :-
CREATE USER "usr" PASSWORD DIGEST '9003d1df22eb4d3820015070385194c8'
ALTER USER "usr" SET LOCAL TRUE
GRANT DBA TO "usr"
I had created DB with user name "usr" so it appeared in script file in those commands. Now while starting server I do not need to specify user name or password. It will IGNORE this information.
While connecting server you have to give exactly same username and password, you gave while creating DB.
Point no 2)
Make sure that there is no space in path of your DB files. If there is space then enclose the whole path in double quotes.
I struggled a lot to find out this silly mistake of mine.
Now if I start the server wil below command it starts correctly
1) Go to lib of HSQL
cd C:\Users\owner\Documents\Java Project\hsqldb-2.2.9\hsqldb\lib
Then give command
java -cp hsqldb.jar org.hsqldb.Server -database.0 file:"C:\Users\owner\Documents\Java Project\hsqldb-2.2.9\TmpDBLocation\myKauDB" -dbname.0 xdb
2) In other command prompt went to lib location
cd C:\Users\owner\Documents\Java Project\hsqldb-2.2.9\hsqldb\lib
Then connected the Swing UI of HSQL DB by giving command in other command prompt window
java -cp hsqldb.jar org.hsqldb.util.DatabaseManagerSwing --driver org.hsqldb.jdbcDriver --URL jdbc:hsqldb:hsql://localhost/xdb --user "usr" --password ""
In my brand new 2.3.2 installation, after clicking bin/runServer.bat, I managed to connect (with Squirrel) using:
URL: jdbc:hsqldb:hsql://localhost:9001
User: SA
Password: <blank>

Categories

Resources