Sonar with SQL Server 2008 - sql-server-2008

I am trying to setup Sonar 3.6 and/or 3.6.2 with SQL Server 2008. For testing in preparation of conversion from MySql to SQL Server. I am getting no errors when running:
sonar.sh console
Console Output:
Running sonar...
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
jvm 1 |
jvm 1 | 2013-07-31 11:41:12.374:INFO:oejs.Server:jetty-7.6.11.v20130520
jvm 1 | JRuby limited openssl loaded. http://jruby.org/openssl
jvm 1 | gem install jruby-openssl for full support.
jvm 1 | 2013-07-31 11:41:43.963:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/,file:/alm/sonar-3.6.2/war/sonar-server/},file:/alm/sonar-3.6.2/war/sonar-server
jvm 1 | 2013-07-31 11:41:44.034:INFO:oejs.AbstractConnector:Started SelectChannelConnector#0.0.0.0:29000
I am running my database on a remote server. This should not be a problem though.
I am able to access the server with the same credentials with DBVisualizer, so I would imagine it should go through with sonar.
The driver I am using is the one bundled with sonar.
The error that I am getting is web based when I try and access the server.
We're sorry, but something went wrong.
Please try back in a few minutes and contact support if the problem persists.
<%= link_to "Go back to the homepage", home_path %>
When I use the h2 embedded database I have no problem accessing it, so I deduce that this is most likely a problem with my database setup.
---------------------------------------------------------
# WEB SETTINGS - STANDALONE MODE ONLY
# These settings are ignored when the war file is deployed to a Java EE server.
#---------------------------------------------------------
# Listen host/port and context path (for example / or /sonar). Default values are 0.0.0.0:9000/.
sonar.web.host: localhost
sonar.web.port: 9500
sonar.web.context: /sonar
# Log HTTP requests. Deactivated by default.
#sonar.web.jettyRequestLogs: ../../logs/jetty-yyyy_mm_dd.request.log
#sonar.web.jetty.threads.min: 5
#sonar.web.jetty.threads.max: 50
#-----------------------------------------------------------------------
# DATABASE
#
# IMPORTANT : the embedded database H2 is used by default.
# It is recommended for tests only. Please use an external database
# for production environment (MySQL, Oracle, Postgresql, SQLServer)
#
#-----------------------------------------------------------------------
#----- Credentials
# Permissions to create tables and indexes must be granted to JDBC user.
# The schema must be created first.
sonar.jdbc.username: sonar
sonar.jdbc.password: sonar
#----- Embedded database H2
# Note : it does not accept connections from remote hosts, so the
# sonar server and the maven plugin must be executed on the same host.
# Comment the following line to deactivate the default embedded database.
#sonar.jdbc.url: jdbc:h2:tcp://localhost:19092/sonar
#sonar.jdbc.driverClassName: org.h2.Driver
# directory containing H2 database files. By default it's the /data directory in the sonar installation.
#sonar.embeddedDatabase.dataDir:/alm/sonar/apache-tomcat-7.0.41/data
# H2 embedded database server listening port, defaults to 9092
#sonar.embeddedDatabase.port: 19092
...
...
#----- Microsoft SQLServer
# The Jtds open source driver is available in extensions/jdbc-driver/mssql. More details on http://jtds.sourceforge.net
sonar.jdbc.url
jdbc:jtds:sqlserver://(REMOTE IP ADDRESS);instance=MSSQLSERVER;databaseName=SONAR;selectMethod=cursor;
# Optional properties
sonar.jdbc.driverClassName: net.sourceforge.jtds.jdbc.Driver
The sonar username that I have has all permissions for the SONAR database.
I am probably missing something small any help is appreciated.

Solved it:
The problem is I needed to create a sonar schema, and associate the sonar user to it for the sonar database.
I also ensured that the sonar user had the permissions that it needed in order to create the database. Started up perfectly.

Related

Liquibase MySQL JDBC Driver connectivity error using liquibase.properties

I am currently evaluating Liquibase as a Database Version Control solution. I am running on Ubuntu 16.04 LTS with java version "1.8.0_181". I have installed Liquibase 3.6.2, I have setup two MySQL 5.7 docker containers on ports 4408 and 4409 for testing, and I have downloaded MySQL Connector/J 8.0 which is recommended for use with MySQL Server 5.7. I placed mysql-connector-java-8.0.12.jar in /usr/local/liquibase/lib/ per the liquibase readme:
The "lib" directory is automatically scanned by the liquibase scripts and all .jar files are added to the classpath.
If you have JDBC drivers or Liquibase extensions that you want to be automatically included, add them to this directory.
In my project test directory I have the following liquibase.properties file:
classpath=/usr/local/liquibase/lib/mysql-connector-java-8.0.12.jar
driver=com.mysql.cj.jdbc.Driver
changeLogFile=db.changelog-1.0.xml
url="jdbc:mysql://localhost:4409/myDatabase"
username=myUser
password=myPassword
I want to generate a changelog from the current state of my development database on port 4409 and then (after integrating routines and triggers) run that changelog on an empty database on port 4408, then do a diff to see if the two are identical and then from there perform a diff with the production database to test how well the changes are integrated. So my first step is to run the following command from the same directory that my liquibase.porperties file is:
liquibase generateChangeLog
The result is the following output:
Starting Liquibase at Thu, 23 Aug 2018 07:37:21 PDT (version 3.6.2 built at 2018-07-03 11:28:09)
Unexpected error running Liquibase: liquibase.exception.DatabaseException: Connection could not be created to "jdbc:mysql://localhost:4409/myDatabase" with driver com.mysql.cj.jdbc.Driver. Possibly the wrong driver for the given database URL
liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to "jdbc:mysql://localhost:4409/myDatabase" with driver com.mysql.cj.jdbc.Driver. Possibly the wrong driver for the given database URL
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:132)
at liquibase.integration.commandline.Main.doMigration(Main.java:953)
at liquibase.integration.commandline.Main.run(Main.java:191)
at liquibase.integration.commandline.Main.main(Main.java:129)
Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to "jdbc:mysql://localhost:4409/myDatabase" with driver com.mysql.cj.jdbc.Driver. Possibly the wrong driver for the given database URL
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:254)
at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:149)
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:97)
... 3 common frames omitted
Caused by: liquibase.exception.DatabaseException: Connection could not be created to "jdbc:mysql://localhost:4409/myDatabase" with driver com.mysql.cj.jdbc.Driver. Possibly the wrong driver for the given database URL
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:249)
... 5 common frames omitted
Note: Since I have included the connector file in the liquibase lib directory, per the quote from the readme above, I shouldn't have to specify the classpath. I have tried it both ways and received the same error. Further, I have tried with mysql-connector-java-5.1.32.jar which is what is in my maven local repo, and adjusted the driver in liquibase properties file to driver=com.mysql.jdbc.Driver, and still the same error.
Now, here is where it gets confusing: If instead of using the liquibase properties file if I execute the following command:
liquibase \
--classpath=/usr/local/liquibase/lib/mysql-connector-java-8.0.12.jar \
--driver=com.mysql.cj.jdbc.Driver \
--changeLogFile=db.changelog-1.0.xml \
--url="jdbc:mysql://localhost:4409/myDatabase" \
--username=myUser \
--password=myPassword \
generateChangeLog
It successfully generates the changelog file with the following output:
Starting Liquibase at Thu, 23 Aug 2018 09:54:41 PDT (version 3.6.2 built at 2018-07-03 11:28:09)
Thu Aug 23 09:54:43 PDT 2018 WARN: Establishing SSL connection without
server's identity verification is not recommended. According to MySQL
5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be
established by default if explicit option isn't set. For compliance
with existing applications not using SSL the verifyServerCertificate
property is set to 'false'. You need either to explicitly disable SSL
by setting useSSL=false, or set useSSL=true and provide truststore for
server certificate verification.
Liquibase command 'generateChangeLog' was executed successfully.
Now, I have other issues that I would like to resolve like why the changelog that is generated includes remarks but when applying the changelog to an empty database the remarks on the first column of every table is not included or when I do a diffChangeLog between the two and try to update the database with the resulting changelog I get and error that changes have validation failures: setColumnRemarks is not supported on mysql, or the the views that the diff generated have replaceIfExists enabled yet the update throws an error that the table already exists. Anyhow, before I post a separate thread for these issues, I thought why not work from the first issue I could not resolve to see if somewhere along the way this may be causing other issues.
So the solution was really simple, I cant believe I didn't see it. In the liquibase.properties file the url should not have quotes. Editing the file to this:
classpath=/usr/local/liquibase/lib/mysql-connector-java-8.0.12.jar
driver=com.mysql.cj.jdbc.Driver
changeLogFile=db.changelog-1.0.xml
url=jdbc:mysql://localhost:4409/myDatabase
username=myUser
password=myPassword
successfully generates the changelog file. It must be the way that the arguments are parse in the properties file vs the command line.

Could not connect to targat machine

Problem Description:
I am going to install MySQL server 5.7.11 (win32) into Windows server 2012. There are several network interface cards being installed in the server, and I am going to install several MySQL instances that bind to specific IP addresses. In short, I am going to install multiple MySQL instances that bind to different IP addresses in same machine.
I am managed to install the first MySQL instance and able to start the service successfully. But when using MySQL Workbench 6.3.6 CE (win32) to connect to the instance, I am getting the following error messages.
RuntimeError: Could not initialize WMI interface:
Workbench.wmiOpenSession(): Could not connect to target machine.
Installer:
mysql-5.7.11-win32.zip (no install)
mysql-workbench-community-6.3.6-win32-noinstall.zip
my.ini configuration:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir=D:/apps/mysql-5.7.11
datadir=D:/apps/nrcc/data
port=3306
bind-address=10.82.95.2
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
MySQL Workbench configuration:
Please see the image below for the configurations. When Workbench is opened and click on the Server Status or Options File, it will prompt to enter a username and password. But then followed by the error messages.
Workbench configurations and error messages
I thought it was because my user do not have WMI permission, so I followed this link Creating a user with Windows Management Instrumentation (WMI) permissions to configure the user, but it still not working. Note that the user is in the local administrators group.
Any help would be much appreciated, thanks!
I managed to remotely connect to my MySQL server from MySQL Workbench running on another server (my application server), although the problem still exist if I do it on the same server.
I have tested that by granting WMI permission to the user in MySQL server, the connection works as intended. The following list shows what I have done:
In MySQL server, add on following groups to the user.
Distributed COM Users
Performance Log Users
Remote Desktop Users
Configure the WMI namespace security assignments
a. Go to Windows Start > Run....
b. Enter wmimgmt.msc and click OK.
c. Right-click WMI Control (Local) and select Properties.
d. Click the Security tab.
e. Click Security.
f. Click Add.
g. Click Advanced.
h. Click Find Now.
i. Select the new user account, and click OK until you return to the Security for Root window.
j. Click Advanced and select the newly added user account.
k. Click Edit.
l. From the Apply to: menu selection, select This namespace and subnamespaces.
m. In Execute Methods, verify that Enable Account, Remote Enable, and Read Security are selected.
n. Click OK until you return to the wmimgmt window.
o. Select File > Exit to exit the wmimgmt window.
I ran into this same problem and it seems Workbench has a small bug. For local WMI management the only way I could get it to work was with 127.0.0.1 But not if I used a DNS/NetBios name or local network address.
I checked with powershell Get-WmiObject and it will return information with any ComputerName locally i.e. 127.0.0.1,192.168.1.126,mycomputername,mycomputername.domain.com.... So I am guessing it has to do with the WorkBench query to wmi not being correct in some manner?
PS:
Get-WmiObject -Query "select * from win32_service where name='MySql8'" -ComputerName 127.0.0.1,192.168.1.126,....(etc)( to check that wmi is working locally )
So in this scenario I just used the loop-back locally to manage the instance with native windows wmi.
Hopefully this saves someone the 2+ hours I just wasted on this exact problem !
This WMI error has nothing to do with MySQL. MySQL Workbench uses Windows Management Instrumentation (WMI) to manage servers locally or remotely in a Windows based environment. WMI is available on all Windows versions and enabled on all customer Windows, but might require extra configuration on server OSes.
So, your best bet is to search how to enable + configure WMI on Windows 2012.

Using SSL with command-line Flywaydb ( flyway ) to deploy DB changes

I'm working on a proof of concept to deploy using flyway's command-line tool from a centralized server to deploy to multiple database platforms. (MySQL, Postgres, and SQL Server)
I'm able to deploy successfully without SSL, however it is using unencrypted host information such as logins/passwords/ports to the destination Database Server. My concern is there's a chance the un-encrypted traffic could be seen.
Does anyone have experience with the flyway command line tool using SSL to deploy to:
MySQL
SQL Server
I did not see any information in the documentation unless I missed it.
Thanks for any help and suggestions!
In the flyway examples in flyway.conf it shows how to add additional values to the jdbc url for example
# MySQL : jdbc:mysql://<host>:<port>/<database>?<key1>=<value1>&<key2>=<value2>...
# PostgreSQL : jdbc:postgresql://<host>:<port>/<database>?<key1>=<value1>&<key2>=<value2>...
# Redshift : jdbc:postgresql://<host>:<port>/<database>?<key1>=<value1>&<key2>=<value2>...
So for Redshift/Postgres for example you can include the ssl=true flag
flyway.url=jdbc:postgresql://yourserver:5439/dbname?ssl=true
You need to add the public key that the DB server key was signed with to your hosts trust store (for Redshift see http://docs.aws.amazon.com/redshift/latest/mgmt/connecting-ssl-support.html for details on that), e.g
${JAVA_HOME}/bin/keytool -keystore ${JAVA_HOME}/lib/security/cacerts -import -alias <alias> -file <certificate_filename>
I then had to hack the flyway startup script /flyway to include the truststore and password in the JAVA_ARGS (it probably should have these as variables) e.g
JAVA_ARGS="-Djava.security.egd=file:/dev/../dev/urandom -Djavax.net.ssl.trustStore=/etc/pki/java/cacerts -Djavax.net.ssl.trustStorePassword=changeit"
For MySQL I used the following URL to connect using SSL.
jdbc:mysql://hostname:3306/wpastudy?useSSL=true
Note the useSSL=true parameter.

where is ejabberd.cfg file available ? How to change db from mnesia to mySQL in windows os?

I am new to ejabberd.I am using ejabberd 15.07 vesion. I want to change the defeault db from mnesia to mySQL server on windows platform.
I came across that we need to do some modifications on ejabberd.cfg file.
Which directory this file is available? please answer..
You will found in lot of documentations which says to modify the ejabberd.cfg file. As per the new releases of ejabberd, the ejabberd.cfg is deprecated. The configuration file for ejabberd is ejabberd.yml. You can find the Config File Formatting in the docs which says the ejabberd configuration file must have .yml or .yaml extension. Directory of this ejabberd config file will be etc directory.
You can change the database to MySQL as:
1) First you need to compile ejabberd with the MySQL support like:
./configure --enable-odbc --enable-mysql
2) Create the tables using the supplied script
mysql < /path/to/mysql.sql
3) Comment your internal authentication method (auth_method) and add the ODBC authentication method
# auth_method: internal ## Commented this line
auth_method: ODBC ## Added this line
4) Then you need to have a connection to MySQL.
odbc_type: mysql
odbc_server: "localhost"
odbc_port: 3306 # the default
odbc_database: "mydb"
odbc_username: "user1"
odbc_password: "userpassword"
odbc_pool_size: 5
You can read the description for the options here
5) Add _odbc to modules you wish to use the odbc database
mod_offline_odbc instead of mod_offline
6) Restart the ejabberd server

Access MySQL server from Grails

I like to setup a dedicated MySQL server in a LAN accessible from other computers of this network. How can I setup the database server and the clients?
How can a Grails application can access the MySQL from the same LAN?
If your MySQL server is going to run on Windows then you can configure it with the installation program. For example, I downloaded the install file mysql-installer-community-5.6.20.0.msi (versions change quickly) and it offers the option of installing just the server:
Just follow the screen prompts and take all the default values (strongly recommended). The main values to remember are:
The default network port number 3306.
The server's ip address.
The username(s) and password(s) that you created that have access to
MySQL.
Then I suggest you download HeidiSQL and configure a connection to your new MySQL server, that way you can manage your database server remotely:
Hope that helps.
You are asking 2 differents questions.
To set up mysql connection in your grails app, did you at least try to read the doc ?
http://grails.org/doc/latest/guide/single.html#dataSource
It's just a jdbc connection string :
https://www.google.fr/?gws_rd=ssl#q=jdbc+mysql+connection+string+example
It's more than just the JDBC connect string. You won't get far without a driver, so uncomment the sample entry in BuildConfig.groovy in the dependencies section and update the version to the most recent:
dependencies {
...
runtime 'mysql:mysql-connector-java:5.1.34'
}
Set the driverClassName in DataSource.groovy, along with the correct JDBC url for your database. Replace <server> with the server name or IP address, and <dbname> with the correct database name. You will likely also want to add parameters at the end of the url in the querystring. And if the port is non-standard (3306 is the default) then add that in also. To ensure that you use INNODB tables (older versions of MySQL default to MyISAM), specify the MySQL5InnoDBDialect (or a subclass):
dataSource {
...
driverClassName = 'com.mysql.jdbc.Driver'
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
url = 'jdbc:mysql://<server>/<dbname>'
}
Run grails compile to download the driver jar and setup the classpath.