how do I make erlang connect with mysql? - mysql

I'm trying to use odbc to connect some erlang code to a mysql server.
I've started up the odbc manager with odbc:start().
But I simply cant get the connect call working,
My connect call looks like this:
odbc:connect("server=localhost;port=3306;Uid=root",[]).
the only thing I have to work with is the error:
{error,"No SQL-driver information available. Connection to database failed."}
If someone could help me I would be most grateful.
/ Martin

I've heard good things about erlang-mysql-driver from #dizzyd.

You don't configure a driver in your DSN. The ODBC system won#t know which to use. Try this:
odbc:connect("driver=MySQL;server=localhost;port=3306;Uid=root",[]).

I heard that exists good non-odbc driver for mysql (but didn`t use it, because have other db). I strongly recommend you to use it, because ODBC application from erlang distribution has many unuseable features and bad docs. You can read my questions here, it mostly related to odbc driver.

I think there is some problem with configuring a driver in your DSN.
Try this,
In your odbc.ini file which is in /etc directory
write this following configuration
[myodbc1]
Driver = /usr/lib/odbc/libmyodbc.so
Description = MySQL ODBC 2.50 Driver DSN
Server = localhost
Port =
User = <Mysql username>
Password = <Mysql password>
Database = <database name>
Option = 3
Socket =
And in your code write the following
Connecting_Str="DSN=myodbc1"
odbc:connect(Connecting_Str,[])
And tell what you get.
.

Related

PowerBuilder MySQL Connection

How do I connect my PowerBuilder to MySQL?
First I would like to use Database Painter to conenct to my local MySQL Database so I can create my datawindows.
Then I would like to make a DSNLESS connection so I can just add .ini and ProfileString my connection.
To create a DSN-less connection, I pulled this syntax from http://www.connectionstrings.com/
ODBC:
SQLCA.DBMS = "ODBC"
SQLCA.DBParm = "Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername;Password=myPassword;Option=3;"
Note that you might have to tweak the version number (5.1) to match the version you download.
// Profile Transporter3
SQLCA.DBMS = "JDBC"
SQLCA.LogPass = "tss"
SQLCA.LogId = "root"
SQLCA.AutoCommit = False
SQLCA.DBParm = "Driver='com.mysql.jdbc.Driver',URL='jdbc:mysql://localhost:3306/mydb'"
the only thing is you need to set classpath of the jar file for which i posted in Linked in please refer
now it connect to MySQL the big problem arises is Ignore space after Function name
I dont understand how to set option for this in JDBC for odbc there is option. i go through documentation
of connector J but no such option. This problem arises only for PowerBuilder so i request you if you know the solution please provide it.
i resolve this issue mysql option -i or --ignore-spaces is going to work so i set that option in configuration files i.e. my.ini
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,IGNORE_SPACE"
stop MySQL service and then started it works smoothly
You have to configurare db profile like servername, database, etc., . In this preview tabpage check the connection and copy &paster the commands in application open event.
By PB team

how to connect Coldfusion to a MySQL database

total newbie and totally lost...
I'm trying to setup coldfusion(8) with a mysql(5.5) database on a local (apache 2.2) webserver running Windows XP.
Coldfusion and Apache are running, but I don't know how to fiddle this in with MySQL.
I'm doing the following:
- Import file1.sql and file2.sql into MySql workbench (5.2) by reverse engineering
- Save this new model as base.mwb into my Apache htdocs folder
- Open the Coldfusion Administrator Data Sources
- Add new Source "myName", Database "base", localhost, 3306, root, password
When I try to add I always get Unknown database 'base' error.
I also tried to make a connection in MySQL or set up a new server instance in MySQL workbench, but these also fail because of no database "base".
I guess I'm missing something (probably a database :-)... Thanks for some pointers or a dummy tutorial. I'm longing for something to show up in http://localhost...
I would have to guess that you are coming from a background using Access DBs. MySQL and ColdFusion do not work together by have a DB file in the CF application. CF connects to a running MySQL server somewhere on your network (even on the same machine) using a JDBC connection. It does not look at a DB file and use that. So you will need to install MySQL Server and then import the DB into that. Then use CF's datasources to connect with that.

Cannot connect Delphi App to mySQL database

I have installed a local server Xampp, which is running mySQL database in Windows. I created a Database on it with one table. The thing is I cannot get a connection to the database when I use the dbExpress TSQLConnection component. When I set the properties as follows:
ConnectionName = MYSQLConnection
Driver = MySQL
Database = databaseName
HostName = localhost
password =
UserName = root
When I change the connected property to true, I get the following error:
Borland.Data.TDBXError: DBX Error: Driver could not be properly initialized. Client library may be missing, not installed properly, of the wrong version, or the driver may be missing from the system path
I have tried making a connection to the database using the Data Explorer, but I still get the above error. I do not know what I'm missing or doing wrong.
Im using Delphi-XE2.
with mySQL on the server: MySQL client version: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $.
I have also tried using an ADO connection, but I do not know how to set the connection string.
I'm still a noob and just want to learn how to make a connection to a mySQL database running on a web server. I cannot afford to buy any components.
Try this!
Did some google Fu - and stumpled upon this link : http://wiltonsoftware.com/posts/view/getting-embarcadero-dbexpress-mysql-working-dbx-error-driver-not-initialized
That seems to fit your needs.
My previous answer was no help .. hope the new one is better.
Old answer:
Make sure you have Data.DBXMySQL in your uses clause.
OK. I'll try a different approach.
Is it working if you setup the connection in the DataExplorer?
If not - then it's not a problem with the uses clause.
(and you obviously have tried that - sry . must be tired :-))
Otherwise a unit could be like this.
unit Unit1;
interface
uses // <-- Uses normally goes right after interface .... (you probably already have one)
Data.DBXMySql;
implementation
end.

Connecting to SQL process with Zend

I'm trying to connect my Zend application to a MySQL process running on a shared server. The basic config should be fine, as it was working with a LAMP server.
The problem is, I need to specify the host as being the an sql process: myprocess.db, rather than localhost:
resources.db.adapter = PDO_MYSQL
resources.db.params.charset = "utf8"
resources.db.params.host = mysqlprocess.db
resources.db.params.username = username
resources.db.params.password = password
resources.db.params.dbname = dbname
However, when I do, I get this:
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]:
Can't connect to local MySQL server through socket 'please_see_the_faq' (2)
in /f5/metamusic/protected/application/controllers/SearchController.php on line 418
The host I'm using is NearlyFreeSpeech, and this message is apparently triggered when attempting to connect to SQL without specifying the process you're interested in:
http://faq.nearlyfreespeech.net/section/mysql/mysqllocalhost#mysqllocalhost
Using the same details and mysql_connect($server, $user) works without issue, so it looks like Zend is somehow not using the correct host parameter.
Any ideas what's going wrong? Any help would be much appreciated.
try using
resources.db.params.host = myprocess.db
The host in the db config has to point to a database server. localhost or 127.0.0.1 are references for the database being on the same server as the application. In a hosting environment you usually have the server on a remote server so the host has to be either an IP address or a DNS name for the host.
Check the second question in the FAQ.
Update
My bad, that is about DSN and not DNS. Still, that's where the problem is. The resources.db.params.host directive in the config expects a reference to the database server and myprocess.db is neither a DNS name nor a IP address. You probably need localhost for that but then you will still be missing the DSN. I currently don't see how you set a DSN in PHP for MySQL and therefore Zend. Have a further look at this MYSQL DSN.
Update 2
You are correct with the socket and that this is related. I think the problem is the Zend PDO_MYSQL adapter. Zend funnels this directly to PDO(). There are this additional config options I mentioned above (MYSQL DSN) which is missing in the Zend implementation. Although the PDO_MYSQL adapter overrides the connect() method it does not look for this options.
However, there is another adapter mysqli which connects directly to MySQL and actually the same way as your test with mysql_connect(). It uses mysqli_real_connect() instead and that connection might understand the process name for the socket. So, you can try the following in your config:
resources.db.adapter = "mysqli"
I'm posting my eventual solution here for future reference:
It turns out, the database connection was already working. However, my call to mysql_real_escape_string() was failing, and the resulting error message suggested that the entire database connection had failed.
The solution was simply to replace the above call with Zend_DB_Adapter's quote(), and suddenly everything works.
Why this works on a LAMP machine and not a shared server, I have no idea. For now though, this is a good enough solution!

Connecting Coldfusion 9 with MySql 5 on Ubuntu 9.10

I've recently set up a Ubuntu 9.10 server with a LAMP configuration and then installed Coldfusion 9 Development version as well.
I've got phpMyAdmin working, so MySql and PHP are fine, and I can serve coldfusion pages, but if I cannot verify my Coldfusion datasource. I get the following error:
Could not create connection to
database server. Attempted reconnect 3
times. Giving up.
With the top of the stack trace showing
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
Could not create connection to
database server. Attempted reconnect 3
times. Giving up.
These are my settings for the datasource in the Coldfusion administrator
JDBC URL jdbc:mysql://192.168.1.19:3306/dbname
Drive class com.mysql.jdbc.Driver
Driver name ConnectorJ 5.1.7
And I know the username and password are correct as they're the same ones I use for phpMyAdmin. Does anyone have any ideas why it's not working?
I'm using almost the same configuration on few boxes and have no such problems, so it looks like you are misconfiguring the datasource.
Are you trying to create the dsn with "MySQL (4/5)" driver? I'm not sure how to read your settings string properly. Is that IP is your localhost? If yes, why not try to use the localhost for server name.
It's a permissions problem. The IP needed to be 192.168.1.19 in the DSN setup in the administrator, but that didn't fix it alone.
I also created a 'temp' MySQL user based on a post found here: http://www.linuxquestions.org/questions/showthread.php?p=4039359#post4039359
And used that instead, it worked.
Try using 127.0.0.1 as the MySQL server address in your DSN configuration