I had a ruby Sinatra app and gem pg to use some Java open source applications, I switched to jruby. This is the output for jruby -S rake db:migrate.
NoMethodError: undefined method `get_oid_type' for #<ActiveRecord::ConnectionAdapters::JdbcAdapter:0x294f9d50>
api/tasks/db.rake:18:in `block in (root)'
rake file
require 'active_record'
require 'jdbc/postgresql'
namespace :db do
task(:environment) do
ActiveRecord::Base.establish_connection(
:adapter => 'jdbc',
:driver => 'org.postgresql.Driver',
:url => 'jdbc:postgresql:db_name',
:username => 'username',
:password => 'password'
)
end
desc 'Migrate the MOT core models (options: VERSION=x, VERBOSE=false)'
task :migrate => :environment do
ActiveRecord::Migration.verbose = true
ActiveRecord::Migrator.migrate "#{File.dirname(__FILE__)}/../db/migrate", ENV['VERSION'] ? ENV['VERSION'].to_i : nil
end
desc 'Rolls the schema back to the previous version of MOT core model(specify steps w/ STEP=n).'
task :rollback => :environment do
step = ENV['STEP'] ? ENV['STEP'].to_i : 1
ActiveRecord::Migrator.rollback "#{File.dirname(__FILE__)}/../db/migrate", ENV['VERSION'] ? ENV['VERSION'].to_i : step
end
end
db.rake:#18
ActiveRecord::Migrator.migrate "#{File.dirname(FILE)}/../db/migrate", ENV['VERSION'] ? ENV['VERSION'].to_i : nil
I am running postgresql with jdbc.
UPDATE
I add the postgresql.jar to my jruby path (jruby installed by brew in my mac) and I am getting the same error. I also removed the jar file and I had driver not found error.
Thanks for your help.
simply use adapter: postgresql in your configuration and it should work just fine.
I found the solution.
First make sure you have the followings in your Gemfile
gem 'activerecord-jdbc-adapter', :require => 'arjdbc'
gem 'activerecord-jdbcpostgresql-adapter'
then in your db migrate task this is the setup for environment:
task(:environment) do
ActiveRecord::Base.establish_connection(
:adapter => 'jdbcpostgresql',
:driver => 'org.postgresql.Driver',
:url => 'jdbc:postgresql://localhost/YOUR_DATABASE_NAME'
)
end
Also this is the database.yaml for development:
development:
adapter: jdbcpostgresql
driver: org.postgresql.Driver
encoding: unicode
url: jdbc:postgresql://localhost/YOUR_DATABASE_NAME
username: USER_NAME
password: PASSWORD
Enjoy your JDBC with Jruby on Sinatra application !!!!
Related
I use MAMP server with PHP 7.1.5; Symfony Framework 3.4.2, PostgreSQL 10 for a new project. I also use PostGIS to store space data with geometry data type in PostgreSQL. Therefore I installed and used: "jsor/doctrine-postgis": "^1.5"
Following is part of my composer.json:
"require": {
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"jsor/doctrine-postgis": "^1.5",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^5.0.0",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.6.4",
"symfony/symfony": "3.4.*",
"twig/twig": "^1.0||^2.0"
The parameters.yml:
server_ver: 10.0
database_driver: pdo_pgsql
database_host: localhost
database_port: 5432
database_name: qtqg
database_path: ~
database_user: postgres
database_password: admin
The config.yml:
doctrine:
dbal:
default_connection: default
connections:
default:
mapping_types:
_text: string
server_version: %server_ver%
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
path: %database_path%
user: %database_user%
password: %database_password%
persistent: true
charset: UTF8
logging: %kernel.debug%
profiling: %kernel.debug%
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: '%kernel.project_dir%/var/data/data.sqlite'
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
#path: '%database_path%'
types:
geography:
class: 'Jsor\Doctrine\PostGIS\Types\GeographyType'
commented: false
geometry:
class: 'Jsor\Doctrine\PostGIS\Types\GeometryType'
commented: false
raster:
class: 'Jsor\Doctrine\PostGIS\Types\RasterType'
commented: false
Everything work well, I can use cmd to generate Entity:
php bin/console doctrine:mapping:import --force AppBundle annotation
And after that generate CRUD:
php bin/console generate:doctrine:crud AppBundleMonitoringAdminBundle:coquan -n --format=annotation --with-write
The Running PHP is PHP 7.1.5 and I also checked php.ini file in C:\Windows and loaded php.ini in MAMP server. php -m command shows:
PDO
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
I don't think any problem with data driver because it can connect and generate Entities, CRUD....
But after generate CRUD and try to access the controller to list all item in one Entity, I got the Error:
An exception occurred in driver: could not find driver
One of the error line is:
AbstractPostgreSQLDriver->convertException('An exception occurred in driver: could not find driver', object(PDOException)) in vendor\doctrine\dbal\lib\Doctrine\DBAL\DBALException.php (line 176)
I tried many way including changing mamp to xamp, wamp server, all recommendation about how to config dbal... but the error is still there
Could anyone help me!
the problem is with PostgreSQL 10
Inside vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php line line 292 change
$data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM ' . $this->_platform->quoteIdentifier($sequenceName));
For
$version = floatval($this->_conn->getWrappedConnection()->getServerVersion());
if ($version >= 10) {
$data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM pg_sequences WHERE schemaname = \'public\' AND sequencename = '.$this->_conn->quote($sequenceName));
}
else
{
$data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM ' . $this->_platform->quoteIdentifier($sequenceName));
}
I was have the same issue with postgres 9.6.4 with WAMP on windows 10
phpinfo() would display pdo_pgsql as loaded, and it worked fine in another PHP application. php -m from the gitbash would not show pdo_pgsql
In the end, I had to edit the php.ini that was loaded and uncomment these 2 lines
extension=php_pdo_pgsql.dll
extension=php_pgsql.dll
restart apache and now it works!!!!
I installed the php 7.0 extensions sqlsrv and pdo_sqlsrv via PECL on my ubuntu 16.04 server in order to connect to a MSSQL database. After this, I restared the entire server.
When calling sqlsrv_connect, I receive the error "Call to undefined function sqlsrv_connect()". The connection string looks like:
$serverName = "serverName";
$connectionInfo = array( "Database"=>" ", "UID"=>" ", "PWD"=>" ");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
I made some checks based on the information I found on google:
php -m shows sqlsrv and pdo_sqlsrv as modules
php -i shows that the php.ini file contains references to additional .ini files for the extensions: /etc/php/7.0/cli/conf.d/sqlsrv.ini and /etc/php/7.0/cli/conf.d/pdo_sqlsrv.ini
cat /etc/php/7.0/cli/conf.d/sqlsrv.ini returns extension=sqlsrv.so which indicates that the .ini file references to the correct extension (same holds for pdo_sqlsrv)
php-config --extension-dir returns /usr/lib/php/20151012 and ls -la /usr/lib/php/20151012 shows -rw-r--r-- 1 root root 326816 Oct 5 14:55 sqlsrv.so which indicates that the extension file is in the correct folder (same holds for pdo_sqlsrv)
php -i | grep sqlsrv returns
/etc/php/7.0/cli/conf.d/pdo_sqlsrv.ini,
/etc/php/7.0/cli/conf.d/sqlsrv.ini,
Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, sqlsrv, phar
PDO drivers => sqlsrv, mysql, sqlite
pdo_sqlsrv
pdo_sqlsrv support => enabled
pdo_sqlsrv.client_buffer_max_kb_size => 10240 => 10240
pdo_sqlsrv.log_severity => 0 => 0
sqlsrv
sqlsrv support => enabled
sqlsrv.ClientBufferMaxKBSize => 10240 => 10240
sqlsrv.LogSeverity => 0 => 0
sqlsrv.LogSubsystems => 0 => 0
sqlsrv.WarningsReturnAsErrors => On => On
Do you have any idea what causes this error and how to fix it? I am happy to provide more information if necessary.
I am new to Yii2. Can anyone tell me how to configure YII2 with mongodb and how to establish connection between YII2 and mongodb? I have tried to download the mongodb package from git hub and tried to run the following command
php composer.phar require --prefer-dist yiisoft/yii2-mongodb "*"
In the command prompt inside the root folder where I have installed Yii2 but I get the following error
Your requirements could not be resolved to an installable set of packages.
Problem 1
- yiisoft/yii2 2.0.0 requires bower-asset/jquery 2.1.*#stable | 1.11.*#stable -> no matching package found.
- yiisoft/yii2 2.0.0 requires bower-asset/jquery 2.1.*#stable | 1.11.*#stable -> no matching package found.
- Installation request for yiisoft/yii2 == 2.0.0.0 -> satisfiable by yiisoft/yii2[2.0.0].
If you are trying to install it through command prompt then try the following command which using composer
composer require --prefer-dist yiisoft/yii2-mongodb "*"
This works in my windows 8 environment.
To ignore dependency errors while installing the package use --ignore-platform-refs switch:
composer require --ignore-platform-refs --prefer-dist yiisoft/yii2-mongodb "*"
Remember that you must also have the MongoDB extension installed in PHP for this plugin to work:
http://php.net/manual/en/class.mongodb.php
Seems like problem was with yii2 composer dependencies, Kindly RUN this command in your console to add global dependencies,
1) composer global require "fxp/composer-asset-plugin:~1.1.1"
2) Add "yiisoft/yii2-mongodb": "~2.0.0" in your composer.json file
3) Now run composer install or composer update
4) Composer install will only install require packages in your composer file but composer update will also check if there is any new release for your packages that you mentioned in composer.js and then install the new release.
5) now add below code in your common/config/main.php file
return [
//....
'components' => [
'mongodb' => [
'class' => '\yii\mongodb\Connection',
'dsn' => 'mongodb://developer:password#localhost:27017/mydatabase',
],
],
];
Now is the time to test either mongoDb working or not.
$collection = Yii::$app->mongodb->getCollection('customer');
$collection->insert(['name' => 'John Smith', 'status' => 1]);
For further information Please follow below link,
https://github.com/yiisoft/yii2-mongodb
'mongodb' => [
'class' => '\yii\mongodb\Connection',
'dsn' => 'mongodb://127.0.0.1:27017/vinagex',
'options' => [
"username" => "vinagex",
"password" => "vinagex"
]
],
i have a tinymca's iframe inside my page and i want to fill_in that tinymca editor with the cucumber test. whenever i run my test it gives me error that jQuery not defined
in my Gemfile
source 'http://rubygems.org'
ruby '2.0.0'
gem 'capybara'
gem 'capybara-mechanize', :git => 'git://github.com/JerryWho/capybara-mechanize.git', :branch => 'relative-redirects'
gem 'rspec'
gem 'cucumber'
gem 'launchy'
gem 'pry'
gem 'selenium-webdriver'
here is my scenario
Scenario: admin puts all the valid and require data
when Job added with all the valid and require data
Then I should see the success message.
and here is the steps for that test
Given(/^I am logged in as a company admin$/) do
visit('/')
fill_in "log", :with => "admin#email.com"
fill_in "pwd", :with => "password"
click_button "submit"
end
When(/^Job added with all the valid and require data$/) do
visit('/site/admin/posts/add/')
within_frame 'questiontextarea_ifr' do
page.execute_script("jQuery(tinymce.editors[0].setContent('my content hersssssssssse'))")
end
click_button "Save"
end
Then(/^I should see the success message\.$/) do
page.should have_content('Success Your post has been successfully added.')
end
but it gives me error jQuery is not defined (Selenium::WebDriver::Error::JavascriptError)
It's most likely because "jQuery is not defined", as the message suggested.
Please try call without jQuery, but with native TinyMCE API:
page.execute_script("tinyMCE.activeEditor.setContent('my content hersssssssssse')")
Further reading: Test WYSIWYG editors using Selenium WebDriver in pure Ruby (not Capybara)
I'm trying to set-up PERL DBD::ODBC to use the DataDirect ODBC Driver Manager (7.0) that is provided with Informatica PowerCenter. This is on a Solaris 10 Sparc64 environment. We've had this working in the past with the 5.1 driver manager (on an sp32 server), but now running into problems since moving to this new version. For all ODBC connections I get this error:
failed: [DataDirect][ODBC lib] Specified driver could not be loaded (SQL-IM003) at test_odbctd.pl line 19
Can't connect to DBI:ODBC:tdedwprd: [DataDirect][ODBC lib] Specified driver could not be loaded (SQL-IM003) at test_odbctd.pl line 19, <STDIN> line 2.
I have tested the same connections using the "ssgodbc" tool provided by Informatica for testing and they work. I can login and run queries.
As an example, here's one of my Teradata connections as definied in odbc.ini (we're having the same problem with DB2, SQL Server, Teradata, Sybase, PowerExchange, etc). Don't ask why I have to hard-code the full driver path in this file instead of odbcinst.ini. I couldn't get it to work and the Informatica standard is to hard-code it in odbc.ini so I don't want to affect our support from them.
[tddev]
Driver=/opt/teradata/client/odbc/drivers/tdata.so
Description=Teradata Development
DBCName=teradata1
DBCName2=teradata2
MaxRespSize=65477
DateTimeFormat=AAA
EnableExtendedStmtInfo=No
LoginTimeout=60
ldd output for the driver:
$ ldd /opt/teradata/client/odbc/drivers/tdata.so
warning: ldd: /opt/teradata/client/odbc/drivers/tdata.so: is not executable
libCstd.so.1 => /opt/SUNWspro/lib/v9/libCstd.so.1
libthread.so.1 => /usr/lib/sparcv9/libthread.so.1
libm.so.1 => /usr/lib/sparcv9/libm.so.1
libw.so.1 => /usr/lib/sparcv9/libw.so.1
libc.so.1 => /usr/lib/sparcv9/libc.so.1
libsocket.so.1 => /usr/lib/sparcv9/libsocket.so.1
libnsl.so.1 => /usr/lib/sparcv9/libnsl.so.1
libxnet.so.1 => /usr/lib/sparcv9/libxnet.so.1
libodbcinst.so => /opt/powercenter/v951/ODBC7.0/lib/libodbcinst.so
libddicu25.so => /opt/teradata/client/odbc/lib/libddicu25.so
libtdparse.so => /opt/teradata/client/odbc/lib/libtdparse.so
libicudatatd.so.46 => /usr/lib/sparcv9/libicudatatd.so.46
libicuuctd.so.46 => /usr/lib/sparcv9/libicuuctd.so.46
libCrun.so.1 => /opt/SUNWspro/prod/usr/lib/v9/libCrun.so.1
libmp.so.2 => /lib/64/libmp.so.2
libmd.so.1 => /lib/64/libmd.so.1
libscf.so.1 => /lib/64/libscf.so.1
libDWicu26.so => /opt/powercenter/v951/ODBC7.0/lib/libDWicu26.so
libdl.so.1 => /usr/lib/sparcv9/libdl.so.1
librt.so.1 => /usr/lib/sparcv9/librt.so.1
libpthread.so.1 => /usr/lib/sparcv9/libpthread.so.1
libdoor.so.1 => /lib/64/libdoor.so.1
libuutil.so.1 => /lib/64/libuutil.so.1
libgen.so.1 => /lib/64/libgen.so.1
libaio.so.1 => /lib/64/libaio.so.1
libm.so.2 => /lib/64/libm.so.2
/lib/sparcv9/../libm/sparcv9/libm_hwcap1.so.2
/platform/sun4v/lib/sparcv9/libc_psr.so.1
/platform/sun4v/lib/sparcv9/libmd_psr.so.1
I tried to run strace as the user that uses these connections, but I get this error so not sure what to do with that:
$ strace perl test_odbctd.pl
ERROR: unable to open /dev/log
Here's the PERL test script we're using:
#!/usr/bin/perl -w
use DBI;
# use DBD::ODBC;
# use DBD::DB2::Constants;
my $data_source = "DBI:ODBC:tdedwprd";
#Prompt for username
print "Enter user:";
my $user = <STDIN>;
#Prompt for password
print "Enter password:";
my $password =<STDIN>;
# Connect to the tdedwdev teradata database
my $dbh = DBI->connect($data_source, $user, $password, {AutoCommit =>1})
or die "Can't connect to $data_source: $DBI::errstr";
$stmt = "SELECT database, time; ";
$sth = $dbh->prepare($stmt);
$sth->execute();
#associate variable with output columns...
$sth->bind_col(1,\$db);
$sth->bind_col(2,\$timestap);
while ($sth->fetch) {
print "The database is: $db\n";
print "The time is: $timestap\n";
}
$dbh->disconnect;
The above script works on our existing dev box (Solaris 10 sp32), but not on the new one we're building (Solaris 10 sp64).
The old server had the driver manager bundled with Informatica PowerCenter 8.6.1 sp32, and the new one has Informatica PowerCenter 9.5.1 sp64.
The DBD::ODBC module did compile fine with some modifications, roughly following this guide from DataDirect (the logic was basically the same, but the references to the Makefile.PL weren't identical):
http://knowledgebase.datadirect.com/articles/Article/2973
I enabled Trace in odbc.ini (Trace=1) but this just resulted in a "Segmentation Fault (core dumped)". However it does output a trace file when using the Informatica-provided "ssgodbc" tool.
I tried using isql, but it seems to be tied to the Sybase drivers so I'm not sure if I can use that. I couldn't get it to work
$ which isql
/opt/sybase/OCS-15_0/bin/isql
Here are my ODBC environment variables:
$ env | grep -i odbc
MANPATH=/usr/share/man:/opt/teradata/client/14.00/odbc_32/help/man:
ODBCINST=/opt/powercenter/v951/ODBC7.0/odbcinst.ini
LD_LIBRARY_PATH=/opt/powercenter/v951/ODBC7.0/lib:/opt/powercenter/v951/server/bin:/home/etlin1d/sqllib/lib:/opt/pwx/v851:/opt/sybase/OCS-15_0/lib:/opt/sybase/OCS-15_0/lib3p64:/opt/sybase/OCS-15_0/lib3p:/opt/teradata/client/14.00/tbuild/lib:/opt/teradata/client/odbc/lib:/opt/teradata/client/odbc/drivers:/opt/teradata/client/14.00/tbuild/lib:/usr/lib:/prj/db2/etlin1d/sqllib/lib64:/prj/db2/etlin1d/sqllib/lib32:/usr/lib
LD_LIBRARY_PATH_64=/opt/powercenter/v951/ODBC7.0/lib:/opt/powercenter/v951/server/bin:/opt/pwx/v851:/prj/db2/etlin1d/sqllib/lib64:/opt/sybase/OCS-15_0/lib:/opt/sybase/OCS-15_0/lib3p64:/opt/sybase/OCS-15_0/lib3p:/opt/teradata/client/14.00/tbuild/lib:/opt/teradata/client/odbc/lib:/opt/teradata/client/odbc/drivers:/usr/lib
NLSPATH=/opt/teradata/client/14.00/odbc_64/msg:/opt/teradata/client/14.00/odbc_32/msg:/opt/teradata/client/14.00/tbuild/msg/%N:/opt/teradata/client/14.00/tbuild/msg/%N:/opt/teradata/client/14.00/odbc_32/msg/%N:
PATH=/opt/sybase/ASEP/bin:/opt/sybase/DBISQL/bin:/opt/sybase/UAF-2_0/bin:/opt/sybase/OCS-15_0/bin:/opt/teradata/client/14.00/tbuild/bin:/opt/teradata/client/14.00/tbuild/bin:/usr/bin:/bin:/usr/local/bin:/opt/powercenter/v951/ODBC7.0/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/powercenter/v951/server/bin:.:/prj/db2/etlin1d/sqllib/bin:/prj/db2/etlin1d/sqllib/adm:/prj/db2/etlin1d/sqllib/misc:/prj/db2/etlin1d/sqllib/db2tss/bin
ODBCINI=/opt/powercenter/v951/ODBC7.0/odbc.ini
ODBCHOME=/opt/powercenter/v951/ODBC7.0
I'm totally at a loss. I'm not a Solaris admin by trade though (in fact this is my first significant exposure to Solaris and Informatica really) so I'm hoping I'm missing something obvious.
I'm not sure what else to share right now. Any help would be GREATLY appreciated. I've been stuck on problems with this ODBC implementation for weeks.
I realised that the problem here was not with the driver manager. It was caused by the fact that I was using 32-bit Perl but a 64-bit ODBC driver. If I added an entry that used a 32-bit ODBC driver to odbc.ini (despite the driver manager being 64-bit) then there is no problem (although it did raise a licensing issue which is separate to this discussion).
In short, this error message occured because the driver is not the same bitness as the client (check by running the file command against both client and driver):
Specified driver could not be loaded
An example of the file command is:
file /opt/teradata/client/odbc/drivers/tdata.so
However, it also occurs when the driver cannot find all of its dependent drivers, which can be checked using ldd on the driver to make sure it is finding all of its dependencies.
An example of the ldd command is:
ldd /opt/teradata/client/odbc/drivers/tdata.so
I tried the above method given by LokMac, all dependant drivers were there and still it wont work, at the end I added "# Driver: The location where the ODBC driver is installed to." before driver path and it magically worked:
[tddemo]
# Driver: The location where the ODBC driver is installed to.
Driver=/opt/teradata/client/16.20/odbc_64/lib/tdataodbc_sb64.so
in above, tddemo is my DNS name and since I am on TD Express 16.20, thats why my driver name is different.