how to connect to a file based HSQLDB database with sqltool? - hsqldb

I have tried to follow the instructions in chapter 1 of the HSQLDB doc and started my server like:
java -cp hsqldb-2.2.5/hsqldb/lib/hsqldb.jar org.hsqldb.Server -database.0 file:#pathtodb# -dbname.0 xdb
and I have reason to believe that worked cause it said (among other things):
Database [index=0, id=0, db=file:#pathtodb#, alias=xdb] opened sucessfully in 2463 ms.
However at the next step I try to connect using SqlTool and based on chapter 8 of the documentation I came up with this command to connect:
java -jar hsqldb-2.2.5/hsqldb/lib/sqltool.jar localhost-sa
Which gives the following error:
Failed to get a connection to 'jdbc:hsqldb:hsql://localhost' as user "SA".
Cause: General error: database alias does not exist
while the server says:
[Server#60072ffb]: [Thread[HSQLDB Connection #4ceafb71,5,HSQLDB Connections #60072ffb]]: database alias= does not exist
I am at a loss. Should I specify alias when connecting somehow? What alias would my database have then? The server did not say anything about that...
(also, yes I have copied the sqltool.rc file to my home folder.

Your server has -dbname.0 xdb as the database alias. Therefore the connection URL should include xdb. For example jdbc:hsqldb:hsql://localhost/xdb
The server can serve several databases with different aliases. The URL without alias corresponds to a server command line that does not include the alias setting.

java -jar /hsqldb-2.3.2/hsqldb/lib/sqltool.jar --inlineRc=url=jdbc:hsqldb:localhost:3333/runtime,user=sa
Enter password for sa: as2dbadmin
SqlTool v. 5337.
JDBC Connection established to a HSQL Database Engine v. 2.3.2 database

This error has been hunting me for the last 5 hours.
Together with this stupid error: HSQL Driver not working?
If you want to run your hsqldb on your servlet with Apache Tomcat it is necessary that you CLOSE the runManagerSwing.bat. I know it sounds trivial but even if you create the desired database and you run Eclipse J22 Servlet with Tomcat afterwards, you will get a bunch of errors. So runManagerSwing.bat must be closed.

See my sqltool answer over on the question "How to see all the tables in an HSQLDB database". The critical piece is setting up your sqltool.rc correctly and putting it in the right location.

You can also use the following statement for getting a connection from a files based store. this can be used if you are running the application from Windows.
connection = DriverManager.getConnection("jdbc:hsqldb:file:///c:/hsqldb/mydb", "SA", "");

Related

Google App Script - MySql 8 - JDBC Connection Failed

I'm trying to connect to a self-hosted MySql 8 instance from a Google AdWords Script (effectively an App Script) using the Jdbc utility over SSL. My code follows the specifications in these answers here and here.
No matter what I do, I still get the following error:
ERROR: Failed to establish a database connection. Check connection string, username and password.
It turns out that the Jdbc utility only works with versions of MySql up to 5.7.
I thought I would post this here posthumously in case I can save someone else time.
The issue has been raised here and marked as fixed recently.
Other related issues can be searched here
it seems like Google has updated the jdbc connector. It is working for me now,

User/Role List could not be obtained pentaho

I am installing pentaho 8.1 CE on ubuntu 16.04
have made change of bd from HSQLDB to Mysql, tables have been created, jackrabbit, hibernate and hibernate.
When starting the server, not login, I imagine that the users are missing or not created. ??
the error that throws me in
catalina.out
ERROR [CompositeUserRoleListService] User / Role List could not be obtained.
java.lang.IllegalStateException: Target of Bean was never resolved: org.springframework.security.core.userdetails.UserDetailsService
atorg.pentaho.platform.engine.core.system.objfac.spring.BeanBuilder$1.invoke(BeanBuilder.java:159)
at com.sun.proxy.$Proxy84.loadUserByUsername(Unknown Source)
..
..
Database Jackrabbit no created tables..
any idea?
When changing the back-end database, there's a few things you need to make sure you check.
repository.xml
quartz.properties
hibernate-settings.xml
[your-database].hibernate.cfg.xml
context.xml (in WEB-INF)
You'll need to confirm the settings for the connection to the new database has been properly configured in all of these different config files. Some additional details on how to config these files for MySQL specifically can be found in the documentation here: https://help.pentaho.com/Documentation/8.1/Setup/Installation/Archive/MySQL_Repository
Past that, make sure that you delete the "repository" directory inside of /pentaho-solutions/system/jackrabbit as this is an index of the repository. If you change your database back-end, then this index needs to be rebuilt. The index is rebuilt automatically if the server sees that "repository" directory doesn't exist at startup.
I've found the same issue on Windows Server 2016 and MySQL8.0, with Pentaho 8.0.2.
Starting Pentaho server from the start-pentaho.bat command, everything was fine.
The problem arise when I was using Tomcat.
The solution was to be sure that Tomcat service was running with the LOCAL SYSTEM account.
If the Tomcat service runs with lower privileges, maybe it can't access to the pentaho-solutions directory and it cannot load the required java beans.
if everything as per the document is configured correctly, then You might be missing the connection change in applicationContext-spring-security-hibernate.properties, please check that.

IIB - DLL Initialization Error in Connecting to DB2 ODBC DSN via mqsicvp

Getting the following error while using mqsicvp to test connectivity to a ODBC data source from IBM Integration Console.
C:\Program Files\IBM\IIB\10.0.0.9>mqsicvp DEFAULTBRK -n MSAPP -v
BIP8299I: User 'db2admin' from security resource name 'odbc::MSAPP' will be used for the connection to datasource 'MSAPP'.
BIP2393E: Database error: ODBC return code '-1' from data source ''MSAPP'' using ODBC driver manager ''odbc32.dll''.
The integration node received an error when processing a database operation. The ODBC return code was '-1'. See the following messages for information obtained from the database about this error.
Use the following messages to determine the cause of the error. Typical problems are an incorrect data source, or table names. Correct either the database or the integration node configuration. Use the mqsicvp command to test connectivity to this database.
BIP2322E: Database error: SQL State ''IM003''; Native Error Code '160'; Error Text ''Specified driver could not be loaded due to system error 1114: A dynamic link library (DLL) initialization routine failed. (IBM DB2 ODBC DRIVER - DB2COPY1, C:\PROGRA~1\IBM\SQLLIB\BIN\DB2CLIO.DLL).''.
The error has the following diagnostic information: SQL State ''IM003'' SQL Native Error Code '160' SQL Error Text ''Specified driver could not be loaded due to system error 1114: A dynamic link library (DLL) initialization routine failed. (IBM DB2 ODBC DRIVER - DB2COPY1, C:\PROGRA~1\IBM\SQLLIB\BIN\DB2CLIO.DLL).''
This message may be accompanied by other messages describing the effect on the integration node itself. Use the reason identified in this message with the accompanying messages to determine the cause of the error. Use the mqsicvp command to test connectivity to this database.
BIP8040E: Unable to connect to the database.
The database cannot be accessed with the specified user Id and password pair.
- Check that the database is running.
- Check that the database has an adequate number of database connections available for use.
- On Windows, check that an ODBC connection has been created.
- On systems that use $ODBCINI, check that the file pointed to by $ODBCINI has been correctly updated.
- On z/OS check the BIPDSNAO member of the component's dataset, and check the DB2 64bit ODBC driver (DSNAO64C) is in the STEPLIB.
- Use mqsisetdbparms to set the password to the correct value and try again.
Software: Windows 10 / IIB 10 / DB2 Server
Steps to reproduce:
Set up ODBC (64-bit) connectivity to a new DB2 database in the form of a System DSN (using the IBM DB2 ODBC Driver version 11.01.2020.1393)
Test that connectivity works from ODBC data source administrator app
Use mqsisetdbparms from IBM Integration Console to set the user and
password
mqsisetdbparms DEFAULTBRK -n odbc::MSAPP -u uid -p pwd
Stop and start the broker
Use mqsicvp to test connectivity
mqsicvp DEFAULTBRK -n MSAPP
The DLL mentioned in the error is at C:\PROGRA~1\IBM\SQLLIB\BIN and this is included within PATH variable already.
I'm not sure why the driver manager odbc32.dll is being used - I presume this is a 32-bit version. However if I try creating a DSN in the 32-bit ODBC data source administrator app, mqsicvp fails with an error saying the architectures do not match.
Suggest you download the fix from IBM for bug IT23069. It is available (indirectly) from this page which eventually redirects to IBM fix central. Worked for me.
The newest developer edition toolkit, 10.0.0.12, seems to have fixed this.

Proper DSN to connect to Sybase using PDO

I'm trying to connect to a Sybase (SQL Anywhere 12) database using PHP's PDO. I spent hours trying to find the correct driver and DSN to use, with NO success AT ALL. Everytime I try to edit a single parameter I always get errors. I tried tens of different combinations of DSN parameters, nothing happens. I'll report here only a few just to give you example of what I'm trying to obtain.
I successfully installed PDO drivers - from php.ini:
PDO drivers dblib, mysql, odbc, pgsql
PDO Driver for FreeTDS/Sybase DB-lib enabled
Flavour freetds
DB params:
The IP for the DB is 192.168.100.234 and both the db instance and db name are GAMMA01. I can't tell you username and password, but let's say: user dba and pwd allright.
I can ping the server from the server where I try to start the connection.
I'm under Linux Debian Squeeze and PHP 5.3.3.
DBLIB:
I'm not able to find the correct DSN to use in order to connect to my Database server.
DSN version 1:
'dblib:host=192.168.100.234;DBN=GAMMA01'
DSN version 2:
'dblib:host=192.168.100.234;DBN=GAMMA01;UID=dba;PWD=allright;Server=GAMMA01;ASTART=No'
DSN version 3:
new PDO('dblib:host=192.168.100.234;dbname=GAMMA01', 'dba', 'allright');
Error I get
SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (severity 9)
FreeTDS error log (trying with both versions 5.0 and 7.0, no difference):
log.c:190:Starting log file for FreeTDS 0.82
on 2014-04-08 13:40:40 with debug flags 0x4fff.
iconv.c:363:iconv to convert client-side data to the "ANSI_X3.4-1968" character set
iconv.c:516:tds_iconv_info_init: converting "US-ASCII"->"UCS-2LE"
iconv.c:516:tds_iconv_info_init: converting "ISO-8859-1"->"UCS-2LE"
net.c:210:Connecting to 192.168.100.234 port 5200 (TDS version 7.0)
net.c:264:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:299:getsockopt(2) reported: Connection refused
util.c:334:tdserror(0xb9a46eb0, 0xb9b60688, 20009, 115)
dblib.c:7782:dbperror(0xb9b5ff88, 20009, 115)
dblib.c:7835:20009: "Unable to connect: Adaptive Server is unavailable or does not exist"
dblib.c:5627:dbgetuserdata(0xb9b5ff88)
dblib.c:7856:"Unable to connect: Adaptive Server is unavailable or does not exist", client returns 2 (INT_CANCEL)
util.c:368:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:389:tdserror: returning TDS_INT_CANCEL(2)
net.c:310:tds_open_socket() failed
dblib.c:1372:dbclose(0xb9b5ff88)
dblib.c:256:dblib_del_connection(0xb5ceea00, 0xb9b60688)
mem.c:563:tds_free_all_results()
dblib.c:303:dblib_release_tds_ctx(1)
dblib.c:5727:dbfreebuf(0xb9b5ff88)
dblib.c:718:dbloginfree(0xb9b46588)
Using sybase: DSN:
'sybase:host=192.168.100.234;dbname=GAMMA01, dba, allright'
Error:
could not find driver
ODBC:
I'm not able to connect with ODBC drivers. I read the guide here: http://www.sybase.com/files/White_Papers/PHP_SQL_Anywhere.pdf and downloaded the proper .so package here: http://scn.sap.com/docs/DOC-40537 but I can't make PHP recognize the package, load it and use it.
DSN:
'odbc:Driver={Sybase SQL Anywhere 12};NA=192.168.100.234,5200;Uid=dba;Pwd=allright;'
'odbc:Driver={SQL Anywhere 12};NA=192.168.100.234,5200;Uid=dba;Pwd=allright;'
'odbc:DRIVER={Sybase SQL Anywhere 12};SRVR=192.168.100.234;DB=gamma01;UID=dba;PWD=allright;'
'odbc:DRIVER={Sybase SQL Anywhere 12};HOSTNAME=192.168.100.234;DATABASE=gamma01;UID=dba;PWD=allright;PROTOCOL:TCPIP'
Error I get:
SQLSTATE[IM002] SQLDriverConnect: 0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified
Which driver should I use to connect to Sybase db? Which is the correct DSN?
The "Data source name not found and no default driver specified." error means that the DSN or Driver you are specifying cannot be found in the odbc.ini file for your ODBC environment.
You need to make sure that your ODBC environment is setup properly. Typically, this includes a specification for the location and file name of the odbc.ini file.
Upon attempting to connect, the odbc.ini file will be searched to find a matching Data Source Name (DSN)
In your case, you are specifying a "Driver". This is a similar configuration usually found in the odbcinst.ini file; also specified by your ODBC environment.
Another thing to check for is to make sure that the ODBC environment is being found by the running process or owning user for your PHP app.
The key is to figure out what part of the connection sequence is failing. In your case, a successful connection would follow this path:
Application is started
ODBC Connection is attempted
ODBC Environment is searched to find the configuration file (usually odbcinst.ini for "Driver" configurations)
Finds a match for the value specified for "Driver=" in connection string
Connection is attempted using the values configured in the found Driver section along with other options provided in connection string.
The two main things that cause the error you are getting are these:
ODBC Environment is not configured
The DSN or Driver value is not spelled correctly.
I hope this helps.
Tony Hall

Migrate mysql users to another server

I have created a mysqldump --all-databases and transferred all my databases to the new server. It didn't work as debian-sys-maintusers password didn't match. So I change the password of this user. After that I restart my server and got this error.
ERROR 1577 (HY000) at line 1: Cannot proceed because system tables
used by Event Scheduler were found damaged at server start ERROR 1547
(HY000) at line 1: Column count of mysql.proc is wrong. Expected 20,
found 16. The table is probably corrupted
I dont know how many more errors will come after this. So I thought create dump with only databases which are associated with my applications (mysqldump --databases).
Now how do migrate the users? Is there any standard way?
More Information:
New Server version: 5.1.63-0+squeeze1 (Debian)
Old Server version: 5.0.51a-24+lenny5 (Debian)
You probably need to run mysql_upgrade, since your MySql versions are different.
As a general rule, however, do not copy the mysql system schema from one server to another. As a consequence, and as far as I know, there is no "standard" way of copying users and user privileges from one server to another.
If you really want/need to do it, try the following:
$> mysql --silent --skip-column-names -e"show grants for user#host"
The above outputs GRANT statements that you can feed straight away into your target server to create the user and give the same authorisations.
However, if your target server is empty, you could just move the whole data folder from your old server to the new server, and then run the standard upgrade procedure from 5.0 to 5.1 on the new server.