PowerBuilder MySQL Connection - mysql

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

Related

CloverETL mySQL Database SSL secure connection & Parameters

I am trying to make the connection to a remote mysql database in CloverETL Designer (Community Version)
Documentation with examples on this subject seem fragmented so I have tried to piece the bits together but I'm not use if they are correct. I would be grateful for any suggestions or further clarification on this subject.
Here is what I have so far:
The SSL Certificate
As an alternative VPN connection the server guys passed me the raw CA certificate, which I saved as a .crt file in the conn folder of the CloverETL workspace.
CloverETL Connections
I created a new DB connection and tested it was working without SSL
In the graph window I created a simple graph
Switching to Source View I added the parameter attribute to the connection code like this:
<Connection database="MYSQL" dbURL="jdbc:mysql://hostname/database_name" id="JDBC0" jdbcSpecific="MYSQL" name="CPM" parameters="ssl=${WORKSPACE}/conn/mysql_cpm_cert.crt" password="password" type="JDBC" user="username"/>
Then I tested the connection to the database by creating new metadata from a DB table
The problem is that I don't know if the connect is now secure or not.
Here's the list of resources that I used to piece together the information:
components:bulkloaders:mysql_data_writer [CloverETL wiki]
MySQL :: MySQL 5.0 Reference Manual :: 6.3.6.3 SSL Command Options
Thanks
CPM
Your setup almost certainly does not use ssl. Both links you posted are not usable - first describes bulk loader and second connection via command line client. But what you need is to configure JDBC. So I would use http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html section "Security."
I would set:
useSSL=true
requireSSL=true
You will do that by adding items in table (Custom JDBC properties) on second tab (Advanced) of Connection Wizard. In source it should appear like "jdbc.useSSL=true jdbc.requireSSL=true" not "parameters=".
Then connection should fail, because in your default java key store is missing your certificate. It can be imported via http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/keytool.html section "Importing Certificates"
I hope this helps.

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.

how do I make erlang connect with 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.
.

Connecting To Local mySql Database

Currently I am connecting to an online mySql database. I would like to switch it to a mySql database on my local hard drive and am having problems with the syntax. Unlike the online one I have no UserID or Password. Any help is appreciated. Thank you.
(mysql_real_connect (conn,"urlock.db.5513143.hostedresource.com","urlock","passxxx","useridxxx",0,NULL,0) !=0);
tried this:
(mysql_real_connect(conn,"c:\urlock.db","urlock","","",0,NULL,0) !=0);
didn't work.
That second parameter needs to be a host which represents a network connection. It cannot be an absolute file reference like you might do with MS Access files. So, you need to install MySQL5.X on your system as a service. If you've done this, verify it by either looking for an open port of 3306 (default) via a 'netstat -an' command or simply look in your services for 'MySQL ....'.
If not, download it here:
http://dev.mysql.com/downloads/mysql/
Once you get this you will be able to import the this database locally and be able to access it very similar to the online version. i.e. (mysql_real_connect(conn,"localhost","urlock","someuser","somepass",0,NULL,0) !=0);
Importing/exporting can be tricky but to point you in the right direction look into the mysqldump command.
I believe the second parameter should be the host. If it is a local mySQL, the
host is localhost.
The default username is usually 'root'.
Try this:
(mysql_real_connect(conn,"localhost","urlock","","root",0,NULL,0) !=0);
Most (if not all) installations of MySQL should have default accounts. There should at least be a root account. http://dev.mysql.com/doc/refman/5.1/en/default-privileges.html
You'll need a CONNECTIONSTRING
SqlConnection con = new SqlConnection(connectionString);
con.Open();
If you add your database in visual studio under Dataconnections, you can see the connection string under properties
ADDED:
If its an sqllite db, you need to use an SQLCeConneciton
private static string connectionString = #"Data Source=path/to/the/database/db.sdf";
private static SqlCeConnection con = new SqlCeConnection(connectionString);

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!