I'm trying to connect my Ruby on Rails application to a legacy Database that is in a Microsoft SQL Server 2008. I have looked around different tutorials, pages, help pages, and question pages and still haven't been able to make it work.
I'm using:
Ubuntu karmic
Rails 2.3.5
Ruby 1.8.7
activerecord-odbc-adapter 2.0
activerecord-sqlserver-adapter 2.3
dbd-odbc 0.2.5
dbi 0.4.3
I also have installed:
freeTDS 0.82-6
tdsodbc 0.82-6
sqsh 2.1-8build1
libodbc-ruby1.8 0.9997-2 (have also tried with 0.9995 and 0.9998)
unixodbc 2.2.11-16ubuntu1
I have managed to connect to the database with tsql, sqsh and isql. But can't connect it through irb nor through rails. Whenever I try I get the following error:
DBI::DatabaseError: **INTERN (0) [RubyODBC]Cannot allocate SQLHENV**
from /var/lib/gems/1.8/gems/dbd-odbc-0.2.5/lib/dbd/odbc/driver.rb:36:in `connect'
from /usr/lib/ruby/1.8/dbi/handles/driver.rb:33:in `connect'
from /usr/lib/ruby/1.8/dbi.rb:142:in `connect'
from (irb):4
It doesn't really matter if I use the odbc-adapter or the sql-adapter, because it always fails in the dbi driver. Any ideas on what can be wrong?
I have the odbc.ini, odbcinst.ini and freetds.conf files properly defined. And they are working with all the other commands to connect (isql, tsql, sqsh).
Please help me or point me somewhere that might help me! =)
PS: I have already followed the following pages with not much success (among others):
wiki.rubyonrails.org/database-support/ms-sql?s[]=sql&s[]=server
piao-tech.blogspot.com/2008/02/using-activerecord-with-microsoft-sql.html
lambie.org/2008/02/28/connecting-to-an-mssql-database-from-ruby-on-ubuntu/
stackoverflow.com/questions/1419397/rubyodbc-cannot-allocate-sqlhenv
This page seems to suggest that the problem may be related to the inability to find a shared library. You should ensure that the system can find any libraries it may need by checking the output of ldconfig -v and ensuring that the folders containing libodbc, libodbcinst and libtdsodbc are included in the library search path. If you are not sure how to do this then this link may help.
If this fails then build the gem manually using the following line
ruby extconf.rb --with-odbc-dir=/folder/to/unixodbc --disable-dlopen
I can't swear that this is the correct answer but it may help. I do have freetds and SQL Server working quite happily with rails on Centos
If you can switch to JRuby ( jruby.org ) you can try using the active-record-jdbc gem with the MS SQL server JDBC driver. I use them to connect to a MS SQL Server 2005 database from Ruby and it works like a charm.
Hope it helps!
Related
I'm trying to configure the plugin dadbod (https://github.com/tpope/vim-dadbod) and must confess I don't know vimscript well enough to comprehend the code :(
I'm stuck on configuring the database adapters. Irrespective of what URL I try, I just get the message
DB: no adapter for SQL Server.
I've also tried SQLite and Postgres with the same results.
In the WIKI, there's a statement: Supports a modern array of backends - which makes me think I haven't configured "the backend" perhaps? I have the jdbc SQL Server driver installed, and set a JAVA_HOME environment variable which works fine with DBeaver and with Azure Data Studio.
I haven't been able to find anything on the web about how to configure dadbod beyond the command structure. Am I missing something obvious about how the plugin works?
Your help greatly appreciated!
The vim-dadbod plugin was definitely not installed correctly. I did a clean install of Vim, then installed the package manager Vundle. Following Vundle's instructions I was able to install vim-dadbod.
I'll be posting a followup later, but the issue is no longer the plugin itself!
I get the error in the attachment during SQL Server 2017 installation. I would like some assistance please.
Look at the Pinal Dave post. It looks like he describes similar issue https://blog.sqlauthority.com/2016/03/07/sql-server-setup-closed-exit-code-0x80004005/
All I can see is that there is something wrong with .NET security. I
asked my .NET expert friend to know if there is any tool to reset the
permission? He told CASPOL.EXE can be used to reset the policies.
Caspol.exe (Code Access Security Policy Tool)
So, we went into following directory
“C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727” and ran this
command: – caspol.exe -machine -reset
C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727>caspol.exe -machine
-reset
If it would have been a 32-bit machine, we would have run the same
command under “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727” folder.
After doing above, the setup was able to start and finish as well.
Have you simply tried fully uninstalling and reinstalling? Including the .net frameworks? Usually, if you completely remove everything that is related in some way to SQL and reinstall, it should complete successfully.
I'm using MySql server on Mac OSX 10.6.7, and I've installed latest version of MySQL Workbench GUI to administrate it. When I try to Export a database, I get a message about mysqldump being version 5.1.34 and therefore incompatible with the server whose version is 5.5.9.
How can I update the mysqldump version to be compatible with my server?
Thanks
Look at the mysql installation folder. Most likely it is /usr/local/mysql/bin
You will find the mysqldump compatible to your mysql version. You need to tell mysqlworkbench to go and fetch mysqlworkbench from this location. To do that, open mysqlworkbench - preferences - admin
Your best bet is to trash what ever mysql server u have installed, and install it via Brew
Link
You can also just install mysql from in addition to the one you are running however this isnt advised.
brew install mysql
hopefully the brew version will be new enough to support it.
Before dumping your old mysql install however, it might be a good idea to do an export via a tool like navicat.
I had some problems to exactly know what and where to put the local path in the preferences.
here are some more detailed infos:
1- Go to mysqlworkbench and edit the preferences:
mysqlworkbench/preferences.../Administartion
2- Edit the "Path to mysqldump Tool:" field and select your local mysqldump
example: /usr/local/Cellar/mysql/5.7.21/bin/mysqldump
I've been doing php before but as usual,I used mysql as a database. So everything seems easy when using xampp.
Now, for some reason I am required to use Oracle as the database but after installing Oracle database 10g on my pc, I can't seem to start apache from the control panel at all! When I press start,instead of it being started it goes back to the stopped state. I tried making it a service and starting it from, it pops out an error.
What is making this conflict, I can use IIS to do this but I prefer xampp so I'm eager to make this thing work.
Does anyone know whats the conflict? Is it the port?
I know how to configure the oracle extension and all with php to get it to work, but I am just confused why apache can't be started when oracle db 10g is installed.
Hope someone can help me out.
I just had this problem with startup.pl not starting (according to the log files), so I went into xampp\apache\conf\httpd.conf and editted out this include line by putting a hash (or pound as it is called in the states) (#) in front of it:
Perl settings
Include "conf/extra/httpd-perl.conf"
it seems to work now and I have now got oracle and apache working on my machine.
Im not sure if there will be any problems later on because of removing the line, but I don't think I need to use anything perl related so hopefully it will be fine
Sounds like platform is Windows. Oracle has the habit to alter the PATH setting, system wide. There is also an Apache installation in the Oracle installation. Maybe you can tweak the Apache service to use the Oracle Apache installation. Otherwise, make sure that your Apache start service does not have ORACLE_HOME or sub-directories of ORACLE_HOME/bin in the PATH. The services that Oracle installs normally are not on the standard ports so it's not very likely that it is a port conflict.
I need to migrate an existing project, built on the current beta of doctrine 2, from mysql to SQL Server.
I have complete control of the SQL Server.
In the DBAL Folder of Doctrine there already is a PDOMsSql driver, but I can't figure out, how to use it. (there is still no documentation)
Doctrine also offers two other ways, I could maybe use:
driverClass: Specifies a custom driver implementation if no 'driver' is specified. This allows the use of custom drivers that are not part of the Doctrine DBAL itself.
pdo: Specifies an existing PDO instance to use.
Could anyone help me with this? I have no clue how to start here, since I have no experience with ODBC/PDO and SQL Server at all.
I figured it out by myself... on a mac, "mssql.so" does only provide "dblib:" as a driver. So by replacing dbo_mssql in the Doctrine Driver with "dblib", defining a FreeTDS host and using its name as the hostname for my connection, everything works fine.
You can also use sqlsrv or pdosqlsrv now. I submitted changes to the pdosqlsrv driver in the Doctrine DBAL project today that fix some things with the DSN creation and get it working. Sqlsrv/pdosqlsrv is probably the way to go imo since Microsoft is actively developing it.