sonarqube
user. Grant this sonarqube
user permissions to create
, update
, and delete
objects for this schema.READ_COMMITED_SNAPSHOT
MUST be set on the SonarQube database.is_read_committed_snapshot_on
is set to true
to prevent SonarQube from facing potential deadlocks under heavy loads. is_read_committed_snapshot_on
:is_read_committed_snapshot_on
:sqljdbc_auth.dll
to any folder in your path. db_owner
database role membership. db_owner
database role membership. sonar.jdbc.username
or sonar.jdbc.password
properties are commented out or SonarQube will use SQL authentication.sonar.jdbc.username
and sonar.jdbc.password
are set appropriately:search_path
property must be set:root
on Unix-based systems, so create a dedicated user account for SonarQube if necessary.admin
/admin
).sonarqube_data
– contains data files, such as the embedded H2 database and Elasticsearch indexessonarqube_logs
– contains SonarQube logs about access, web process, CE process, and Elasticsearchsonarqube_extensions
– will contain any plugins you install and the Oracle JDBC driver if necessary.sonar_extensions
volume. To do this:sonarqube_extensions/jdbc-driver/oracle
.SONARQUBE_JDBC_USERNAME
, SONARQUBE_JDBC_PASSWORD
, and SONARQUBE_JDBC_URL
is deprecated and will stop working in future releases..yml
file. Click the heading below to expand the .yml
file.sonarqube_conf
, sonarqube_data
, sonarqube_logs
, and sonarqube_extensions
and start the image with the following command. This will populate all the volumes (copying default plugins, create the Elasticsearch data folder, create the sonar.properties configuration file). Watch the logs, and, once the container is properly started, you can force-exit (ctrl+c) and proceed to the next step.sonar.jdbc.url
, sonar.jdbc.username
, sonar.jdbc.password
and sonar.web.javaAdditionalOpts
in sonar.properties
is not working, and you will need to explicitly define theses values in the docker run command with the -e
flag.$SONARQUBE_HOME/extensions/jdbc-driver/oracle
.$SONARQUBE_HOME/conf/sonar.properties
.Note that if your proxy username contains a backslash, then it should be escaped - for example username 'domainuser' in file should look like:root
, that means SonarQube can't be either. You must choose some other, non-root
account with which to run SonarQube, preferably an account dedicated to the purpose.OS | Start |
---|---|
Windows | Click [Start], [All Programs], [H2], and [H2 Console (Command Line)] An icon will be added to the system tray: If you don't get the window and the system tray icon, then maybe Java is not installed correctly (in this case, try another way to start the application). A browser window should open and point to the login page at http://localhost:8082 . |
Windows | Open a file browser, navigate to h2/bin , and double click on h2.bat .A console window appears. If there is a problem, you will see an error message in this window. A browser window will open and point to the login page (URL: http://localhost:8082 ). |
Any | Double click on the h2*.jar file. This only works if the .jar suffix is associated with Java. |
Any | Open a console window, navigate to the directory h2/bin , and type: |
webPort
.http://localhost:8082
.If you want to connect to the application from another computer, you need to provide the IP address of the server, for example:http://192.168.0.2:8082
.If you enabled TLS on the server side, the URL needs to start with https://
.H2DRIVERS
or CLASSPATH
.Example (Windows): to add the HSQLDB JDBC driverC:Programshsqldblibhsqldb.jar
, set the environment variableH2DRIVERS
toC:Programshsqldblibhsqldb.jar
.;
(Windows)or :
(other operating systems).Spaces in the path names are supported. The settings must not be quoted.SELECT * FROM ..
is added.While typing a query, the table that was used is expanded in the tree.For example if you type SELECT * FROM TEST T WHERE T.
then the table TEST is expanded.;
before the command.Command(s) | Description |
---|---|
@autocommit_true; @autocommit_false; | Enable or disable autocommit. |
@cancel; | Cancel the currently running statement. |
@columns null null TEST; @index_info null null TEST; @tables; @tables null null TEST; | Call the corresponding DatabaseMetaData.get method. Patterns are case sensitive (usually identifiers are uppercase). For information about the parameters, see the Javadoc documentation. Missing parameters at the end of the line are set to null. The complete list of metadata commands is: @attributes, @best_row_identifier, @catalogs, @columns, @column_privileges, @cross_references, @exported_keys, @imported_keys, @index_info, @primary_keys, @procedures, @procedure_columns, @schemas, @super_tables, @super_types, @tables, @table_privileges, @table_types, @type_info, @udts, @version_columns |
@edit select * from test; | Use an updatable result set. |
@generated insert into test() values(); @generated(1) insert into test() values(); @generated(ID, 'TIMESTAMP') insert into test() values(); | Show the result of Statement.getGeneratedKeys() . Names or one-based indexes of required columns can be optionally specified. |
@history; | List the command history. |
@info; | Display the result of various Connection and DatabaseMetaData methods. |
@list select * from test; | Show the result set in list format (each column on its own line, with row numbers). |
@loop 1000 select ?, ?/*rnd*/; @loop 1000 @statement select ?; | Run the statement this many times. Parameters (? ) are set using a loop from 0 up to x - 1. Random values are used for each ?/*rnd*/ . A Statement object is used instead of a PreparedStatement if @statement is used. Result sets are read until ResultSet.next() returns false . Timing information is printed. |
@maxrows 20; | Set the maximum number of rows to display. |
@memory; | Show the used and free memory. This will call System.gc() . |
@meta select 1; | List the ResultSetMetaData after running the query. |
@parameter_meta select ?; | Show the result of the PreparedStatement.getParameterMetaData() calls. The statement is not executed. |
@prof_start; call hash('SHA256', ', 1000000); @prof_stop; | Start/stop the built-in profiling tool. The top 3 stack traces of the statement(s) between start and stop are listed (if there are 3). |
@prof_start; @sleep 10; @prof_stop; | Sleep for a number of seconds. Used to profile a long running query or operation that is running in another session (but in the same process). |
@transaction_isolation; @transaction_isolation 2; | Display (without parameters) or change (with parameters 1, 2, 4, 8) the transaction isolation level. |
.h2.server.properties
in you user home directory.For Windows installations, the user home directory is usuallyC:Documents and Settings[username]
orC:Users[username]
.The configuration file contains the settings of the application and is automatically created when the H2 Console is first started.Supported settings are:webAllowOthers
: allow other computers to connect.webPort
: the port of the H2 ConsolewebSSL
: use encrypted TLS (HTTPS) connections.webAdminPassword
: password to access preferences and tools of H2 Console.<number>=<name>|<driver>|<url>|<user>
using the escape character
.Example:1=Generic H2 (Embedded)|org.h2.Driver|jdbc:h2:~/test|sa
DriverManager.getConnection()
).The driver name is 'org.h2.Driver'
.The database URL always needs to start with jdbc:h2:
to be recognized by this database. The second parameter in the getConnection()
callis the user name (sa
for System Administrator in this example). The third parameter is the password.In this database, user names are not case sensitive, but passwords are.-ifNotExists
parameter toTCP, PG, or Web servers (but not to the Console tool).Its combination with -tcpAllowOthers
, -pgAllowOthers
, or -webAllowOthers
effectively creates a remote security hole in your system, if you use it, always guard your ports with a firewallor some other solution and use such combination of settings only in trusted networks.Server
tool.Starting the server doesn't open a database - databases are opened as soon as a client connects.Server
tool from the command line with the default settings, run:org.h2.Driver
jdbc:h2:tcp://localhost/~/test
-tcpPassword
(the same password must be used to start and stop the TCP server).H2Dialect
if possible.When using the H2Dialect
,compatibility modes such as MODE=MySQL
are not supported.When using such a compatibility mode, use the Hibernate dialect for thecorresponding database instead of the H2Dialect
;but please note H2 does not support all features of all databases.org.h2.jdbcx.JdbcDataSource
. You can set this in the GUIat Application Server - Resources - JDBC - Connection Pools,or by editing the file sun-resources.xml
: at elementjdbc-connection-pool
, set the attributedatasource-classname
to org.h2.jdbcx.JdbcDataSource
.H2Platform
.The source code of this platform is included in H2 atsrc/tools/oracle/toplink/essentials/platform/database/DatabasePlatform.java.txt
.You will need to copy this file to your application, and rename it to .java.To enable it, change the following setting in persistence.xml:toplink.platform.class.name
.glassfish/glassfish/lib
.org.eclipse.persistence.platform.database.H2Platform
.If this platform is not available in your version of EclipseLink, you can use the OraclePlatform instead in many case.See also H2Platform.TransactDatabaseLocker
instead of the default locking mechanism. Otherwise the database file will grow without bounds. The problem is that thedefault locking mechanism uses an uncommitted UPDATE
transaction, which keeps the transaction logfrom shrinking (causes the database file to grow). Instead of using an UPDATE
statement, the TransactDatabaseLocker
usesSELECT .. FOR UPDATE
which is not problematic.To use it, change the ApacheMQ configuration element <jdbcPersistenceAdapter>
element, propertydatabaseLocker='org.apache.activemq.store.jdbc.adapter.TransactDatabaseLocker'
.However, using the MVCC mode will again result in the same problem. Therefore, please do not use the MVCC mode in this case.Another (more dangerous) solution is to set useDatabaseLock
to false.SELECT COUNT(*) FROM <query>
is run.This is a problem for queries that modify state, such as SELECT NEXT VALUE FOR SEQ
.In this case, two sequence values are allocated instead of just one.codegen.xml
is on the classpath and contains this informationshared/lib
orserver/lib
directory. It is a good idea to open the database when theweb application starts, and close it when the web application stops.If using multiple applications, only one (any) of them needs to dothat. In the application, an idea is to use one connection perSession, or even one connection per request (action). Thoseconnections should be closed after use if possible (but it's not thatbad if they don't get closed).context-param
and the filter
section):DbStarter.java
.By default this tool opens an embedded connectionusing the database URL jdbc:h2:~/test
,user name sa
, and password sa
.If you want to use this connection within your servlet, you can access as follows:DbStarter
can also start the TCP server, however this is disabled by default.To enable it, use the parameter db.tcpServer
in the file web.xml
.Here is the complete list of options.These options need to be placed between the description
tagand the listener
/ filter
tags:DbStarter
, it will also be stopped automatically.h2*.jar
file in your application, andadd the following configuration to your web.xml
:src/tools/WEB-INF/web.xml
.h2small-*.jar
can be used.To create the smaller jar file, run the command ./build.sh jarSmall
(Linux / Mac OS)or build.bat jarSmall
(Windows).javax.sql.
classes are not available on Android.CSVREAD
and CSVWRITE
,or it can be used outside the database as a standalone tool.CSVREAD
. Example:CSVREAD
should not be used inside a join.Instead, import the data first (possibly into a temporary table), create the required indexesif necessary, and then query this table.INSERT INTO .. SELECT
.CSVWRITE
can be used to create a CSV file from a query.Example:Csv
tool can be used in a Java application even when not using a database at all.Example:Script
tool is ran as follows:SCRIPT
to create the backup of the database.For more information about the options, see the SQL command SCRIPT
.The backup can be done remotely, however the file will be created on the server side.The built in FTP server could be used to retrieve the file from the server.RunScript
tool:RUNSCRIPT
.The restore can be done remotely, however the file needs to be on the server side.The built in FTP server could be used to copy the file to the server.It is also possible to use the SQL command RUNSCRIPT
to execute a SQL script.SQL script files may contain references to other script files, in the form ofRUNSCRIPT
commands. However, when using the server mode, the references script filesneed to be available on the server side.BACKUP
SQL statement and the Backup
tool both create a zip filewith the database file. However, the contents of this file are not human readable.Backup
tool (org.h2.tools.Backup
) can not be used to create a online backup;the database must not be in use while running this program.Backup
creates a backup of a database.ChangeFileEncryption
allows changing the file encryption password or algorithm of a database.Console
starts the browser based H2 Console.ConvertTraceFile
converts a .trace.db file to a Java application and SQL script.CreateCluster
creates a cluster from a standalone database.DeleteDbFiles
deletes all files belonging to a database.Recover
helps recovering a corrupted database.Restore
restores a backup of a database.RunScript
runs a SQL script against a database.Script
allows converting a database to a SQL script for backup or migration.Server
is used in the server mode to start a H2 server.Shell
is a command line database tool.;
.This allows to enter multi-line statements:jdbc:h2:~/test
org.h2.Driver
jdbc:h2:~/test
org.h2.Driver
java.security.AccessControlException
:access denied (java.io.FilePermission .. read
).Example permission tags:DriverManager.getConnection()
.The build-in connection pool is used as follows:FT_SEARCH_DATA('Hello', 0, 0);
.The result contains the columns SCHEMA
(the schema name),TABLE
(the table name),COLUMNS
(an array of column names), andKEYS
(an array of objects).To join a table, use a join as in:SELECT T.* FROM FT_SEARCH_DATA('Hello', 0, 0) FT, TEST TWHERE FT.TABLE='TEST' AND T.ID=FT.KEYS[0];
H2DRIVERS
orCLASSPATH
.To initialize the Lucene fulltext search in a database, call:FTL_SEARCH_DATA('Hello', 0, 0);
.The result contains the columns SCHEMA
(the schema name),TABLE
(the table name),COLUMNS
(an array of column names),and KEYS
(an array of objects). To join a table, use a join as in:SELECT T.* FROM FTL_SEARCH_DATA('Hello', 0, 0) FT, TEST TWHERE FT.TABLE='TEST' AND T.ID=FT.KEYS[0];
@
and can be used whereverexpressions or parameters are allowed. Variables are not persisted and session scoped, that means only visiblefrom within the session in which they are defined. A value is usually assigned using the SET command:NULL
.The data type of a user-defined variable is the data typeof the value assigned to it, that means it is not necessary (or possible) to declare variable names before using them.There are no restrictions on the assigned values; large objects (LOBs) are supported as well.Rolling back a transaction does not affect the value of a user-defined variable.destroy-method
will help prevent exceptions on hot-redeployment or when restarting the server.OSGI_JDBC_DRIVER_CLASS=org.h2.Driver
and OSGI_JDBC_DRIVER_NAME=H2 JDBC Driver
.The OSGI_JDBC_DRIVER_VERSION
property reflects the version of the driver as is.JDBC_USER, JDBC_PASSWORD, JDBC_DESCRIPTION, JDBC_DATASOURCE_NAME, JDBC_NETWORK_PROTOCOL, JDBC_URL, JDBC_SERVER_NAME, JDBC_PORT_NUMBER
.Any other standard property will be rejected.Non-standard properties will be passed on to H2 in the connection URL.;JMX=TRUE
to the database URL when opening the database.Various tools support JMX, one such tool is the jconsole
.When opening the jconsole
Download the elder scrolls online mac. , connect to the process where the database is open(when using the server mode, you need to connect to the server process). Then go to the MBeans
section.Under org.h2
you will find one entry per database. The object name of the entryis the database short name, plus the path (each colon is replaced with an underscore character).CacheSize
: the cache size currently in use in KB.CacheSizeMax
(read/write): the maximum cache size in KB.Exclusive
: whether this database is open in exclusive mode or not.FileReadCount
: the number of file read operations since the database was opened.FileSize
: the file size in KB.FileWriteCount
: the number of file write operations since the database was opened.FileWriteCountTotal
: the number of file write operations since the database was created.LogMode
(read/write): the current transaction log mode. See SET LOG
for details.Mode
: the compatibility mode (REGULAR
if no compatibility mode is used).MultiThreaded
: true if multi-threaded is enabled.Mvcc
: true if MVCC
is enabled.ReadOnly
: true if the database is read-only.TraceLevel
(read/write): the file trace level.Version
: the database version in use.listSettings
: list the database settings.listSessions
: list the open sessions, including currently executing statement (if any) and locked tables (if any).com.sun.management.jmxremote
andcom.sun.management.jmxremote.port
as required by the JVM.