How to connect to a SQLite DB with Agile Toolkit 4? - atk4

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.

Related

How to connect SQL Views to HTML 5 Webpage

I have a question I was hoping to get some feedback on being that it is my first time doing something like this.
I am building an intranet site and need to display a SQL view from SQL Server. I've done some research online and I've seen some people say use PHP to connect to the DB, then HTML to build a table... but those scenarios have been for MySQL or Access databases, not SQL Server.
My question is: what is the best way to to go about connecting and displaying a SQL Server view to an HTML 5 page? (I'm mainly just asking for some suggestions on where to start, any good documentation to look at, etc. not looking for someone to code it for me or anything like that)
First of all, you do not want to connect to the database directly from client side code, direct database queries should always be done on the server side.
I'd recommend using PHP because it's fairly simple, lightweight and widely supported.
You can query SQL Server with PHP, although you may need to download and install the PHP PDO drivers from Microsoft in order to do this. (Google 'sql server php pdo driver' and you'll be able to find them for your particular platform)
Alternatively you may be able to use an ODBC driver instead, although I haven't tried that personally.
In PHP you can use PDO to open a connection to your database, select from the view into an associative array using something like the following:
$pdo_object = new PDO($dsn, $user, $password);
$statement = $pdo_object->prepare("SELECT column1, column2 FROM view1");
$statement->execute();
$data = $statement->fetchAll(PDO::FETCH_ASSOC);
From here you can iterate over this data to render a table or pass it into javascript and have that populate a data grid.

Error when trying to install sonarqube on SQL Server 2008

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

Using nvarchar cfsqltype in coldfusion with jtds jdbc

Firstly, my cconfig is:
Language: ColdFusion 10(and installed update 11)
DB is MS SQL Server 2012
Using the jtds jdbc(tried versions 1.2.6, 1.2.8 and 1.3.0)
I'm currently having a problem running queries where I use cfqueryparam with a cfsqltype of cf_sql_nvarchar. The problem is the page just hangs. If I look at the application log of ColdFusion, I see the error of:
"net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setNString(ILjava/lang/String;)V The specific sequence of files included or processed is:" followed by the test filename.
I'm running a very basic select query on a nvarchar column, but the page doesn't load and that error is logged.
I know it's gotta be something to do with the jtds jdbc as if I connect through the regular sql driver it'll work perfectly.
So did anybody experience this before? If so, what was your resolution?
Thanks
I did a quick search and the results suggest jtds does not support setNString(). I checked the driver source for 1.3.1, and as mentioned in the comments here the method is not implemented:
"..while getNString is implemented the code just consists of // TODO
Auto-generated method stub and throw new AbstractMethodError();.."
So it sounds like you may need to use cf_sql_varchar, combined with the "String Format" setting, like in previous versions. Obviously, the other option is to use a different driver (one that does support setNString(), such as Adobe's driver or the MS SQL Server driver).
Try using cf_sql_varchar. cf_sql_nvarchar is not a valid option according to the Documentation and you should use cf_sql_varchar

can not PDO nuodb

I want to connect nuonb with yii framework. After i configed from this guide (configuring database connection in Yii framework)
I cannot connect to database.
So I look at another page that config nuodb with php Framework.
http://www.nuodb.com/techblog/2013/06/20/using-nuodb-from-the-php-zend-framework/
I configed and test in command line I think it work case after i use this command
php -i | grep PDO
The Result is
----------------------------------------
PDO support => enabled
PDO drivers => mysql
PDO Driver for MySQL => enabled
But when I use function to test PDO in php with function phpInfo(), It can't find nuodb PDO ( PDO is no value).
Please help me fix this problem.
Remark. My server is Aws Ec2 Ubunto.
I wouldn't trust this "nuodb" at all. Looks like a bubble.
You didn't install nuodb anyway, but mysql.
So - just go on with mysql!
#Sarun Prasomsri
What version of NuoDB are you running?
What version of PHP? (supported versions are PHP 5.4 TS VC9 and PHP 5.3 TS VC9)
# Your Common Sense
NuoDB does install - it can run on a localmachine, datacenter, or AWS/Azure/Google Compute, like any other Database.
There are concrete details in the online doc: http://doc.nuodb.com/display/doc/NuoDB+Online+Documentation
techblog: http://dev.nuodb.com/techblog

How to configure ODBC Data Source Administrator (DSA) for MS Access db?

I ultimately want to query an existing MS-Access database (say, contacts.mdb) from a Lazarus program I will write.
It appears that configuring a User DSN is the first step.
In the ODBC DSA, I am stuck at Adding a driver for MS-Access databases. What do I need to download for this?
OK, I'm starting over from scratch. Please bear with me.
I'm now trying to use the Lazarus example given at wiki.lazarus.freepascal.org/MS_Access.
Following the Instruction given as "Goto your [Data sources (ODBC)] at the control panel administrative tools..." I run /usr/bin/ODBCConfig and get an error which says "Invalid window handle." Clicking OK closes without anything.
Does this mean I've gotten everything so FUBAR that's it's hopeless?
If your program is written in PHP you can use php5-odbc for access any odbc source, like mssql server or access databases.
This post http://phplens.com/phpeverywhere/node/view/9 illustrate you all the necessary step.
Thsi might be the thing you need
http://www.easysoft.com/products/data_access/odbc-access-driver/
I think it should be enough to put something like the following in ~/.odbc.ini:
[Contacts]
Description = The Contacts Database
Driver = /usr/lib/libmdbodbc.so
Database = /home/dkjmusic/data/contacts.mdb
Of course you need an MDB ODBC driver (e.g. libmdbodbc Install libmdbodbc http://bit.ly/software-small) to be installed

Resources