avatar

Andres Jaimes

Calling a DLL from MQL

There are times when we want access to additional data structures and function libraries than the ones provided by MetaTrader’s MQL. Besides native open-source MQL options, we can create our own Dynamic Link Library (DLL) in C# or C++ and link it to our programs. In this article, we research how to connect to DLLs created with these languages. We must keep in mind that the code generated by C# is managed code running on the .

From MySQL to Postgres - Useful commands

This article shows a list of basic commands on MySQL and their corresponding versions for PostgreSQL. Connecting to a database MySQL $ mysql -u root -p Postgres $ psql -h <host> -U <username> <database-name> Try the following if you don’t know the name of the available databases: psql -h <host> -U <username> -l Some installations add your current user to the list of allowed users to the database. In that case you can connect without specifying a username.

Storing MySQL credentials on a file

MySQL allows you to store credentials in a file called ~/.my.cnf. The contents can look like this: [mysqldump] user=myuser password=mypassword We have to modify the file permissions and give read/write permissions to the owner only: chmod 600 ~/.my.cnf And done. We can now use it: mysqldump mydatabase mysqldump is going to read the credentials from that file.

Common tasks when working with MySQL

How to install MySQL server in Ubuntu It’s pretty simple: sudo apt-get install mysql-server How to connect to MySQL using Java This is a useful and simple snippet: import java.sql.Connection; import java.sql.DriverManager; public class Test { public static void main(String[] args) { try { Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection( "jdbc:mysql://localhost/?user=root&password="); c.close(); System.out.println("Success"); } catch (Exception e) { e.printStackTrace(); } } } How to connect to MySQL using C# Go to http://www.

Create a connection to MySQL in Java

This time we are going to create a basic connection to MySQL in Java and pull some data from it. // Compile it: // javac Mysql.java // // Try it: // java -classpath mysql-connector-java-5.1.27-bin.jar:. MySQL import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; public class MySQL { public Connection getConnection() throws SQLException { Connection conn = null; Properties p = new Properties(); p.put("user", "username"); p.put("password", "superpassword"); String cs = "jdbc:mysql://localhost/demo"; conn = DriverManager.

How to connect to MySQL from a remote server

In few words, you have to configure MySQL to allow remote connections, create a user for connecting and setup your firewall to allow it. You don’t have to do this if you are only connecting from a local application like WordPress. You need root permissions to perform the following commands.  Configuring MySQL Edit the MySQL configuration file. nano /etc/my.cnf Allow connections from all your network interfaces by commenting out the following line:

1000 song names SQL test data

This time I want to share a 1000 rows SQL table that you can use for text searches. It includes a table with 1 column, 1000 rows song title names. It is plain standard SQL so you can use it with any database manager. Download it here. Hope you find it useful.