mysql on SonarQube is bloated - java

I am using SonarQube 4.5 with mysql.
Here's the part in the system information:
Version 4.5
Database MySQL 5.5.40
Database URL jdbc:mysql://localhost:3306/sonar? useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
Database Login sonar
Database Driver MySQL Connector Java mysql-connector-java-5.1.27 ( Revision: alexander.soklakov#oracle.com-20131021093118-gtm1bh1vb450xipt )
When running the Hudson build I get an exception, which among other says:
SQL: select c.id, c.kee as kee, c.issue_key as issueKey, c.user_login as userLogin, c.change_type as changeType, c.change_data as changeData, c.created_at as createdAt, c.updated_at as updatedAt, c.issue_change_creation_date as issueChangeCreationDate from issue_changes c inner join issues i on i.kee = c.issue_key inner join (select p.id,p.kee from projects p where (p.root_id=? and p.qualifier <> 'BRC') or (p.id=?)) p on p.id=i.component_id WHERE c.change_type=? and i.status <> 'CLOSED' order by c.issue_change_creation_date asc
Cause: java.sql.SQLException: Got error 28 from storage engine
I have set up the Delete all snapshots after to 10.
When I go to sonar-home/data, I see a huge file sonar.h2.db
can I delete it?
Where's the mySQL data located?
Thanks,

If you're using MySQL, you should not have sonar.h2.db files in $SONAR_HOME/data folder (this is only when you run SonarQube with the built-in H2 DB for test purposes).
The error you get from MySQL tells you that you don't have enough space, see 1030 Got error 28 from storage engine.

Related

H2 memory DB test can't find table TAB

I use H2 memory DB to do my test integration and my real BD is oracle DB
jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;Mode=Oracle
When I want to use this SQL to check if my table exists
SELECT TNAME FROM TAB WHERE TNAME='myTableName'
But in the execution test, I got the error message "Table "TAB" not found".
What could I do to use this oracle table?
Create the table TAB in integration script sql and simule the fonctionnement Oracle ...

HSQLDB Unexpected token: GETDATE

JPA & Hibernate application uses HSQLDB for JUnit tests.
HSQLDB 1.8.0
Hibernate 3.2.4.sp1
Java 7
While the tests worked fine against an Oracle database, getting the following error now that we are using MSSQL 2016:
Unexpected token: GETDATE in statement [select ..... effective_date < GETDATE() AND ... ]
So I understand that HSQL uses SYSDATE, CURDATE, or NOW instead of the MSSQL GETDATE function, and I've done the following:
Attempted to set sql.syntax_mss to true by URL and SQL statement:
public static final String HYPERSONIC_JDBC_URL = "jdbc:hsqldb:mem:aname;sql.syntax_mss=true";
entityManager.createNativeQuery("set database sql syntax MSS true").executeUpdate();
Register the function in the Dialect and/or create a function:
registerFunction("GETDATE", new NoArgSQLFunction("SYSDATE", new DateType()));
entityManager.createNativeQuery("CREATE FUNCTION GETDATE() RETURNS DATE RETURN CURDATE()").executeUpdate();
None of this seems to have any effect.
Live application is connected to MS SQL Server 2016 via mssql-jdbc-6.2.1.jre7 driver.
So while upgrading the libraries as #fredt mentioned in the comments is probably the best route, upgrading hsqldb.jar breaks dbunit.jar, upgrading that breaks.. etc.
Was able to remove the GETDATE occurrences and fix the sequence generation strings (select next value for seq_name from seq_name is the format it likes) and now we are back to a working state.
Upgrading these libraries can be put in the bucket with upgrading jBoss, Hiberate, jBPM and Quartz :)

for Query in DB2 via jdbc not working

I have a query in Maximo which when run via DB visualizer runs fine. but the same query when I run in java via jdbc it throws sql exception.
The query is a bit different than usual and is shown below.
It gives the next sequence number for the next entry.
select nextval for mytabledseq from sysibm.sysdummy1
I have found the issue. I had to add the schema name before mytableseq.
e.g. MAXIMO.mytableseq now it works fine

General syntax error raised from CONNECT BY query in Informix when using quoted table identifiers

When running the following query on an Informix database, the database reports a general syntax error (without any indication with respect to what causes the problem). The same query runs perfectly on CUBRID or Oracle databases, both of which also support the CONNECT BY syntax:
select
lower(connect_by_root "t_directory"."name"),
connect_by_isleaf,
connect_by_iscycle,
substr(
sys_connect_by_path(lower("t_directory"."name"), '/'),
2) "dir"
from "t_directory"
start with "t_directory"."parent_id" is null
connect by nocycle prior "t_directory"."id" = "t_directory"."parent_id"
order siblings by lower("t_directory"."name") asc
The database I'm using is a Developer Edition of Informix 12.10 on Windows. I'm running the query from a JDBC driver with the following connection URL (to allow for quoted table identifiers):
jdbc:informix-sqli://localhost:9092/test:INFORMIXSERVER=ol_informix;DELIMIDENT=y
The exact issue here is the fact that prior doesn't accept quoted table identifiers, although quoted column identifiers seem to be fine. This query runs perfectly well:
select
lower(connect_by_root "t_directory"."name"),
connect_by_isleaf,
connect_by_iscycle,
substr(
sys_connect_by_path(lower("t_directory"."name"), '/'),
2) "dir"
from "t_directory"
start with "t_directory"."parent_id" is null
connect by nocycle prior t_directory."id" = "t_directory"."parent_id"
order siblings by lower("t_directory"."name") asc
... with the difference being:
-- Bad:
connect by nocycle prior "t_directory"."id" = "t_directory"."parent_id"
-- Good:
connect by nocycle prior t_directory."id" = "t_directory"."parent_id"

H2: "data conversion error" in WHERE clause

I am using the H2 database (v1.3.170) for JUnit testing in my project. Our production environment uses Oracle DB so we have to do lot conversions of the DDLs exported from Oracle to make them working with H2. One of the issues we are facing right now is following:
select * from table_country c where c.code > 0 AND 'USA' = c.name(+)
This query works fine in Oracle, but fails in H2 with below stack trace:
org.h2.jdbc.JdbcSQLException: Data conversion error converting "USA"; SQL statement:
select * from table_country c where c.code>0 AND 'USA' = c.name(+) [22018-170]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:158)
at org.h2.value.Value.convertTo(Value.java:852)
at org.h2.value.Value.getBoolean(Value.java:373)
at org.h2.expression.ConditionAndOr.optimize(ConditionAndOr.java:188)
at org.h2.command.dml.Select.prepare(Select.java:802)
at org.h2.command.Parser.prepareCommand(Parser.java:218)
at org.h2.engine.Session.prepareLocal(Session.java:414)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:253)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:149)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NumberFormatException
at java.math.BigDecimal.<init>(Unknown Source)
at java.math.BigDecimal.<init>(Unknown Source)
at org.h2.value.Value.convertTo(Value.java:801)
... 8 more
I tried removing the (+) - it worked:
select * from table_country c where c.code > 0 AND 'USA' = c.name
But as I said, I don't want to change this in production (want the Oracle => H2 conversion to be transparent).
Please suggest what could be the issue and a better way to solve this?
(+) syntax for outer joins is deprecated in Oracle. Stop using it.
In your case an "outer join" doesn't really makes sense anyway because you are not joining.
You probably want something like this (which works reliably across all DBMS)
select *
from table_country c
where c.code > 0
and (c.name = 'USA' or c.name is null);
A final word: using a different DBMS for testing and production makes your tests worthless. There are too many subtle differences between the DBMS that you simply can't cover when using different DBMS.

Categories