Has anyone got this working?
I know the docs say that ms sql support is not tested, so I wonder if anyone had it working?
I have enabled the Db module in acceptance.suite.yml
And my credentials in codeception.yml look like this:
modules:
config:
Db:
dsn: 'mssql:host=******.db.8876686.hostedresource.com;dbname=*******'
user: '*******'
password: '******'
dump: app/tests/_data/dump.sql
In my cest file, I have the following function:
public function testUserDb(WebGuy $I)
{
$I->seeInDatabase('Users',['Email' => 'someguy#email.com']);
}
But I get the following error when running:
[Codeception\Exception\Module]
(Exception in Db) could not find driver while creating PDO connection
So I'm guessing ms sql doesn't work..
It looks like I'm not going to have any joy - anyone know if Behat has ms sql / sql server support?
Thanks
Jon.
Behat itself doesn't have anything to do with databases. If you need connecting to one from a Behat context file, you just use whatever is used in your application.
I've successfully used Doctrine with Behat for example, also with mssql.
For mssql integration you will need the doctrine-pdo-dblib package.
Related
I'm trying to set up a Debezium SQL Server Connector against a SQL Server instance that is controlled by DBAs at my workplace. I've been able to start up Zookeeper and Kafka Server without issue, and Kafka Connect itself works with sample Connectors, but when attempting to start a Debezium SQL Server Connector instance I've been getting the error "Couldn't obtain database name".
[2022-07-12 16:36:04,269] ERROR Stopping after connector error (org.apache.kafka.connect.cli.ConnectStandalone:117)
java.util.concurrent.ExecutionException: org.apache.kafka.connect.runtime.rest.errors.BadRequestException: Connector configuration is invalid and contains the following 1 error(s):
Unable to connect. Check this and other connection properties. Error: Couldn't obtain database name
Here is my debezium config:
name=Dbz-SqlServer-connector
connector.class=io.debezium.connector.sqlserver.SqlServerConnector
database.hostname=MyDbHost
database.port=1433
database.user=MyUsername
database.password=MyPassword
database.dbname=MyDatabase
database.server.name=MyDbHost
table.include.list=dbo.CdcTest
database.history.kafka.bootstrap.servers=localhost:9092
database.history.kafka.topic=dbhistory.CdcTest
I've tried this in a .properties file passed to a standalone Connect instance, and as a JSON POST to a distributed Connect instance. I have tried all of the same steps on both my local Windows machine as well as on a linux VM, with the same results.
Confluent and Docker are not options for me in this situation.
for SQL Server login credentials, I am using a local account on the SQL Server instance that does have access to the database in question. I found the source code for debezium's connectors on their github and was able to find that specific error message within the code:
private static final String GET_DATABASE_NAME = "SELECT name FROM sys.databases WHERE name = ?";
...
public String retrieveRealDatabaseName(String databaseName) {
try {
return prepareQueryAndMap(GET_DATABASE_NAME,
ps -> ps.setString(1, databaseName),
singleResultMapper(rs -> rs.getString(1), "Could not retrieve exactly one database name"));
}
catch (SQLException e) {
throw new RuntimeException("Couldn't obtain database name", e);
}
}
I'm not completely familiar with Java but it appears that basically something is going wrong when the connector is trying to run "SELECT name FROM sys.databases WHERE name = 'MyDatabase'". When I run this against the database myself, logged in with the same account I'm using, it seems to work just fine, so I'm really not sure where to go from here. It is fair to say that since I'm not in full control of the SQL Server environment that I'm using, there may be some permissions issues that I'm not aware of, but from what I'm able to test it seems like it should be working.
I would greatly appreciate any help at all, whether just suggestions on settings/configs to check or a full-blown solution.
Thank you!
Update: I've built a simple console app to run that sys.databases query against MyDbHost, master database, as the relevant account, and it's working just fine so I feel like that confirms that my connection info is correct and account permissions are also correct. Seems like this is an issue within the Debezium connector.
It turned out that my problem was a mistake in the connector's config setting. I misunderstood which specific pieces of data to put into database.hostname and database.server.name, and one I corrected those fields the connector works.
I'm new to ITRS Monitoring, and I am wondering if I could create a Geneos alert that can connect to a MSSQL DB and run a simple select to make sure connectivity is good. Is this possible with Geneos? Are there any plugins needed?
Yes - you can use sql toolkit plug-in. It supports Db2, Oracle, SQL Server, MySql and Sybase. It will look something like this:
I'm trying FastReport.Mono on Linux (CentOS 7) to see if I can make an app to generate reports. Example Mono app seems to work fine with PDF and JPG export from custom dataset.
Now I need to query data from MS SQL database. I have a sample report that works well under Windows, but fails on Linux:
private static void ReportExportJPG()
{
Report report = new Report();
report.Load(#"sql-report.frx");
report.Prepare(); // <<<--- Error here
...
}
Error message is:
Cant find object MsSqlDataConnection
Feature table says that MS SQL connectivity (nor ODBC, nor many others) is not available in FastReport.Mono. Does this mean it's entirely missing or I should use other ways and provide ready-made connection to FastReport somehow? If so - How?
P.S. Running Windows report generator with MS SQL connection under Wine works well, so I assume connecting to MS SQL from CentOS is somehow viable.
I was able to resolve this by adding the following to my project source:
using FastReport.Data;
using FastReport.Utils;
...
RegisteredObjects.AddConnection(typeof(MsSqlDataConnection));
When I try to install sonarqube database I get some errors and database is not created
ActiveRecord::JDBCError: The driver encountered an unknown error: unable to choose type for timestamp from:
["datetime2", "datetime"]
initialize at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection.rb:66
initialize at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:31
jdbc_connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/connection_methods.rb:6
send at org/jruby/RubyKernel.java:2227
new_connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:223
checkout_new_connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:245
checkout at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:188
loop at org/jruby/RubyKernel.java:1519
checkout at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:184
mon_synchronize at jar:file:/C:/sonarqube/web/WEB-INF/lib/jruby-complete-1.7.9.jar!/META-INF/jruby.home/lib/ruby/1.8/monitor.rb:191
checkout at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:183
connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:98
retrieve_connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_pool.rb:326
retrieve_connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_specification.rb:123
connection at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/connection_specification.rb:115
initialize at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:440
up at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:401
migrate at C:/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:383
upgrade_and_start at C:/sonarqube/web/WEB-INF/config/../lib/database_version.rb:62
automatic_setup at C:/sonarqube/web/WEB-INF/config/../lib/database_version.rb:74
(root) at C:/sonarqube/web/WEB-INF/config/environment.rb:239
load at org/jruby/RubyKernel.java:1094
(root) at file:/C:/sonarqube/web/WEB-INF/lib/jruby-rack-1.1.13.2.jar!/jruby/rack/rails/environment2.rb:1
load_environment at file:/C:/sonarqube/web/WEB-INF/lib/jruby-rack-1.1.13.2.jar!/jruby/rack/rails/environment2.rb:25
load_environment at file:/C:/sonarqube/web/WEB-INF/lib/jruby-rack-1.1.13.2.jar!/jruby/rack/rails_booter.rb:79
i was reading about and looks like database driver is not working alright
Any clues about how can i get this working on SQL Server?
There might be a problem with the locale settings of the database. In my case it helped to set the language for the sonarqube database user to "English". See here.
After a few tries, I changed the SQL driver (sqljdbc4.jar) to one directly from Microsoft, it looks like my previous driver was third party modified.
http://www.microsoft.com/en-us/download/confirmation.aspx?id=21599 this is the original mssql driver form jdbc.
http://www.sezok.de/sonar/sonar.html this guide was helpful too.
after changing driver, everything works OK
I'd like to use SQLite3 with Agile Toolkit. I found it in the documentation that the SQLite driver is included with atk4, but I couldn't find any examples of how to connect to a SQLite DB.
I tried to change the DB connection of the example applications shipped with atk4 from MySql to SQLite using the format found in the Pear:DB DSN documentation:
$config['dsn']='sqlite:////var/www/webdev/atk4_example.db';
but I keep getting the could not find driver PDO error:
Application Error: Database Connection Failed
BaseException, code: 0
Additional information:
* PDO error: could not find driver
* DSN: :host=;dbname=;charset=utf8
/var/www/webdev/atk4/lib/DB.php:94
The SQLite PDO driver seems to be installed correctly on the server. Both the phpinfo() and an PHP/PDO/SQLite3 example page confirms that it works.
I'm learning Agile Toolkit, PHP and general web development, so I might be missing something trivial.
Can you try following syntax in your config.php?
$config['dsn']='sqlite://username:password#hostname/dbname';
Also please check if you have MySQL (yes, MySQL not SQLite) extension enabled in your php.ini. If not, then try to enable it and test again. If SQLite works with enabled MySQL extension then I guess I have found small bug in DB.php and could fix that.
Also it looks that you can pass DSN parameters in following format as array and maybe that's even better:
$config['dsn'] = array(
'sqlite:host=hostname;dbname=dbname;charset=utf8',
'username',
'password'
);
Please try 2 solutions described above and let me know if they work.
I can't test that myself now because I'm not at my developing computer.