I followed the steps trying to configure MySQL in WildFly. I have two questions for your help with:
1) I downloaded the mysql-connector-java-5.1.33-bin.jar and placed it under modules/system/layers/base/com/mysql/main/. Do I need to download the actual MySql? Or the connector jar is sufficient?
2) In creating a new data source in WildFly console, I was not able to create a new data source. Part of the information I need to fill in is a pair of user name and password to access the database. Where should I create this user name and password first? I am guessing this is where I got the problem from.
I got this error message when testing the connection in wildfly console:
Unexpected HTTP response: 500
Request
{
"address" => [
("subsystem" => "datasources"),
("data-source" => "mysqlDSPool")
],
"operation" => "test-connection-in-pool"
}
Response
Internal Server Error
{
"outcome" => "failed",
"failure-description" => "JBAS010440: failed to invoke operation: JBAS010447: Connection is not valid",
"rolled-back" => true
}
first you need to install Mysql server and a JDBC 4-compliant driver, normally all new JDBCs provided by Mysql.org are JDBC 4-compliant, find a platform independant one here, then you need to add a datasource here in this file standalone/configuration/standalone.xml or using this command
data-source add --name=myDataSource--jndi-name="java:jboss/datasources/myDataSource" \
--connection-url="jdbc:mysql://localhost:3306/myDB" \
--driver-name=h2 --user-name="myDB_Username" --password="myPassword"
username and password are those used to connect to Mysql database.
1) You need to download the jdbc-driver jar which, I think, is the connector jar. But please don't place it under modules/system/... but directly under modules since the system folder is reserved for internal modules that are delivered with the server.
2) Here is an example (configures an Oracle datasource):
/subsystem=datasources/jdbc-driver=OracleJdbcDriver:add(driver-module-name=oracle.jdbcaq,driver-name=OracleJdbcDriver)
/subsystem=datasources/data-source=OracleDS:add(jndi-name=java:jboss/datasources/OracleDS,enabled=true,jta=true,use-java-context=true,connection-url=jdbc:oracle:oci:#dbms:1523/DEV,driver-name=OracleJdbcDriver,min-pool-size=5,max-pool-size=100,user-name=username,password=password,prepared-statements-cache-size=100,exception-sorter-class-name=org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter)
Related
I'm setting up a web API. My program.cs file looks like this:
var serverVersion = new MySqlServerVersion(new Version(8, 0, 29));
builder.Services.AddDbContext<GameDbContext>(
dbContextOptions => dbContextOptions
.UseMySql(builder.Configuration.GetConnectionString("Db"), serverVersion, mySqlOptions =>
mySqlOptions.EnableRetryOnFailure(
maxRetryCount: 10,
maxRetryDelay: TimeSpan.FromSeconds(30),
errorNumbersToAdd: null))
);
And my connection string has the following template:
"ConnectionStrings": {
"Db": "Server=serverIP,port;Database=dbName;User Id=userId;Password=password;"
}
The API ill listen on localhost:7272 when building and running the project in Visual Studio itself. The API will handle the requests sent to this adress.
However, when I build and publish the project and then run the executable from the folder, it listens to localhost:5000, but no requests will be handled because of this error:
An error occurred using the connection to database '' on server ''.
I've already added the 'EnableRetryOnFailure' as suggested by others and changed the template of the connection string multiple times but still to no avail.
What can I do to fix this?
Thanks!
I've already added the 'EnableRetryOnFailure' as suggested by others and changed the template of the connection string multiple times but still to no avail. I also added the Pomelo package.
I am facing this error while starting logstash.
I have configured MYSQL db as input in logstash.
Pipeline_id:main
Plugin: <LogStash::Inputs::Jdbc jdbc_user=>"admin", jdbc_password=><password>, statement=>"SELECT * from table", jdbc_driver_library=>"/usr/s$
Error: Permission denied - /.logstash_jdbc_last_run
Exception: Errno::EACCES
Stack: org/jruby/RubyIO.java:1237:in `sysopen'
org/jruby/RubyIO.java:3800:in `write'
The last_run_metadata_path option defaults to "#{ENV['HOME']}/.logstash_jdbc_last_run", and it looks like that evaluates to /.logstash_jdbc_last_run. You are getting EACCES because you do not have write access to the root directory.
To fix it, set the last_run_metadata_path option to a file in a directory that you have write access to. If you have an input configuration that starts with
input {
jdbc {
jdbc_driver_library => "mysql-connector-java-5.1.36-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
you can just add an additional line there
last_run_metadata_path => "/tmp/.logstash_jdbc_last_run"
using some path that you know you can write to and that nobody else will be using.
I want to build a simple app that connects to remote MySQL server. However, I can't make it work.
import ballerina/io;
import ballerina/jdbc;
import ballerina/mysql;
endpoint jdbc:Client jiraDB {
host: "jdbc:mysql://DB-SERVER:3306/jira",
username: "jira",
password: "PWD",
poolOptions: { maximumPoolSize: 5 }
};
type Domain record {
string domain,
string jira,
};
function main(string... args) {
var ret = jiraDB->select("SELECT * FROM `domains`", ());
table domainTable;
match ret {
table tableReturned => domainTable = tableReturned;
error e => io:println("Select data from domains table failed: " + e.message);
}
while(domainTable.hasNext()) {
var domain = <Domain>domainTable.getNext();
match domain {
Domain d => io:println("Domain: " + d.domain);
error e => io:println("Error in get employee from table: "
+ e.message);
}
}
}
The structure of MySQL is not really important. I think it has to do with missing / wrongly used JDBC/MySQL library.
Do you please have any ideas how to make it work on Mac OS X ?
$ ballerina run hello.bal
error: ballerina/runtime:CallFailedException, message: call failed
at ..<stop>(hello.bal:5)
caused by error
at ballerina/jdbc:stop(endpoint.bal:66)
I'm using latest Mac OS X with:
$ ballerina --version
Ballerina 0.980.1
First, the latest ballerina version is 0.981.0. It would be great if you could use the latest version since it would include latest bug fixes and improvements.
In Ballerina, there is a generic jdbc client which can be used to connect to any database which has a jdbc driver. In addition, for mysql and h2 there are two clients implemented specifically for those two databases.
When connecting to mysql, you could either use the generic jdbc client or the mysql specific client. The recommendation is to use the mysql specific client.
In your code snippet, I can see you are using jdbc client. As Anoukh mentioned above, the endpoint configuration is incorrect.
Following is a sample configuration for generic jdbc client endpoint.
endpoint jdbc:Client testDB {
url: "jdbc:mysql://localhost:3306/testdb",
username: "user1",
password: "pass1",
poolOptions: { maximumPoolSize: 5 }
};
And following is a sample configuration of mysql client endpoint.
endpoint mysql:Client testDB {
host: "localhost",
port: 3306,
name: "testDB",
username: "user1",
password: "pass1",
poolOptions: { maximumPoolSize: 5 }
};
In order to use either of the clients, you need to copy the mysql jdbc driver to ${BALLERINA_HOME}/bre/lib.
Even after correcting your configuration and copying the driver, if you still face the issue, please check whether file named ballerina-internal.log is created where you are running your bal file and share. Also please share the mysql database and driver version you are using.
Have you copied the MySQL JDBC driver to the BALLERINA_HOME/bre/lib folder?
You can find the ballerina home using which ballerina command.
You can download the mysql jdbc driver from http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar
The issue might be in the jiraDB endpoint configurations. As per the API docs, the config for the URL of the database is to be given as url instead of host.
I was not able to connect to Mysql and I faced a driver instance error. I solved it! I'm not sure to post my answer at the good place but I think it will be a good resource to fix some problems with Mysql connections issues in Ballerina.
In my terminal : echo $BALLERINA_HOME
/Library/Ballerina/ballerina-0.990.2
Copy the good jar in the right place !
Go to : http://central.maven.org/maven2/mysql/mysql-connector-java/
I have downloaded the latest stable version (at the time of writing 8.0.15).
Copy the jar in $BALLERINA_HOME/bre/lib/
I had an error with a prior version.
Be careful that your jar have the right extension (the .jar not the repository with the same name).
Also be sure to have fulfilled the recommandations (see the doc of Oracle when installing a jar, i.e setting the classpath)
In your terminal, set the class path :
export CLASSPATH=$CLASSPATH:/Library/Ballerina/ballerina-0.990.2/bre/lib/mysql-connector-java-8.0.15
Then it will work !
I am trying to import data from MySQL to Elasticsearch using logstash version.
Versions of software used:
Java/JRE 1.8
Elasticsearch 6.1.0
Logstash 6.1.0
My conf contents are as follows:
file: simple-out.conf
input {
jdbc {
# MySQL jdbc connection string to our database, mydb
jdbc_connection_string => "jdbc:mysql://valid/validDBNAME?useSSL=false"
# The user we wish to execute our statement as
jdbc_user => "MY USER"
jdbc_password => "MY PWD"
# The path to our downloaded jdbc driver
jdbc_driver_library => "C:\JavaDevelopment\TomcatServer\apache-tomcat-8.5.20\lib\mysql-connector-java-5.1.45-bin.jar"
# The name of the driver class for Postgresql
jdbc_driver_class => "com.mysql.jdbc.Driver"
# our query
statement => "SELECT * from testtable"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
}
}
output {
stdout { codec => json_lines }
elasticsearch {
hosts => "http://localhost:9200"
index => "test-migrate"
document_type => "data"
}
}
When I run logstash I get the following error:
[2017-12-19T16:50:08,055][ERROR][logstash.pipeline ] Pipeline aborted due to error {:pipeline_id=>"main", :exception=>#<NameError: SSLConnectionSocketFactory not found ERROR
Please suggest how to get past this.
Thanks
Try adding httpclient-VERSION.jar, httpcore-VERSION.jar files to LOGSTASH_HOME/vendor/jruby/lib/ folder.
I had same problem, the solution is:
add LOGSTASH_HOME variable path in environment variables in mycomputer properities to C:\some_path\logstash-6.3.0
then add these files to C:\some_path\logstash-6.3.0\logstash-core\lib\jars
files:
httpclient-4.5.2.jar
log4j-1.2.17.jar
httpcore-VERSION.jar
this is because logstash doesn't come with ssl jar file and you need to add this to jar folder and set the environment so as logstash can read those jar files
and try using gitbash rather than cmd or powershell!
and try to close and restart your logstash and elasticsearch
follow this link to see which index are comming to elasticsearch.
http://localhost:9200/_cat/indices?v
if you are running on diff. port please change port number
addidional tips
and it didn't work for me on jdk 10.x so use jdk 8.x
and maybe installer wont work even so just unzip file and run elasticsearch.bat and logstash -f cong_filepath\configfile.config in bin folders
windows user can type cmd in top of path
Please make sure MySQL is running, (doesn't mean open) on server
Learn # https://www.elastic.co/blog/logstash-jdbc-input-plugin
To resolve it yourself in future:
open logstash/bin folder and right click and gitbash (need git)
type "vi log" and press tab 3 times till all logstahsh files are shown up
a new line will appear, type "vi logstash" and press enter to open source file
you'll have code to understand flow,.. if you look carefully Logstash_home and javacmd (at bottom) are important that execute jar, javacmd should be set to your java_home variable in env variables to jdk8.x and Logstash_home has a path for jar directory, either change it or put you jar to this folder.
Hope this helps!
With Drush v8.0.3 in both sides (local is a Mac and desarrollo is a Linux Server with CPanel), I'm executing:
sql-sync #project.local #project.desarrollo
and getting this error at the end of the process (everything else works):
ERROR 1045 (28000): Access denied for user 'myremotehostuser'#'localhost' (using password: YES)
My alias file includes this:
$aliases['desarrollo'] = array (
'root' => '/home/myremotehostuser/subdomains/project/',
'uri' => 'http://project.myremotehost.com',
'remote-user' => 'myremotehostuser',
'remote-host' => 'myremotehost.com',
'path-aliases' => array(
'%dump-dir' => '/tmp',
),
'source-command-specific' => array (
'sql-sync' => array (
'no-cache' => TRUE,
'structure-tables-key' => 'common',
),
),
'command-specific' => array (
'sql-sync' => array (
'sanitize' => TRUE,
'no-ordered-dump' => TRUE,
'structure-tables' => array(
'common' => array('cache', 'cache_filter', 'cache_menu', 'cache_page', 'history', 'sessions', 'watchdog'),
),
),
),
);
And drush status on "desarrollo" returns:
Drupal version : 7.41
Site URI : http://project.myremotehost.com
Database driver : mysql
Database hostname : localhost
Database port :
Database username : databaseuser
Database name : databasename
PHP configuration : /usr/local/lib/php.ini
PHP OS : Linux
Drush script : /usr/local/bin/drush
Drush version : 8.0.3
Drush temp directory : /tmp
Drush configuration :
Drush alias files :
Drupal root : /home/myremotehostuser/subdomains/project/
Drupal Settings File : sites/default/settings.php
Site path : sites/default
As you can see, the "database owner" (a MySQL user) is not the same as "remote-host" (a CPanel user).
Drush is supossed to scan the setting files in both sides to figure out the right config, if I'm not wrong, you don't even have to add a $databases array or a db-url string since v7. Then, why is it trying to access the db with 'myremotehostuser'#'localhost' instead of 'databaseuser'#'localhost'?
In this case, there is no database user called 'myremotehostuser' and I guess that I could solve the problem by creating it and granting permissions for 'databasename' but I'm almost sure I'm missing something really dumb here and there must be a simple solution.
edit:
Trying the same alias file in the same server with host user name and database user name still being different, but this time in a freshly created account, seems to work prefectly. So I guess the problem it's being caused by some CPanel/WHM configuration issue rather than any Drush related thing. I will keep trying this a couple of times before closing the question.
I encountered this issue too. It turns out drush is first looking for the file ~/.my.cnf and if it's found, it'll use it to connect. The file contains the username and password.
[client]
user=myremotehostuser
Once I temporarily remove this file, drush can dump the sql successfully using the site's settings.php.
Repeating the rsync and sql-sync processes in new accounts work without problem. The issue only happens in this already created account, with multiple databases, users, and prefixes. I don't have full access to this account so I can't test it properly.
This issue was too specific and probably didn't deserve a question by itself since it's almost impossible to replicate. I'll consider it "solved" and will update it in the case I find out why it's not working.