Pregunta

I am using Database toolbox of Matlab to run my MySQL queries. I am doing this by using JDBC driver (Connector/J).

I am able to connect/create/delete new tables for a given database.

Is there a way by which I can directly create a new database from Matlab itself? I'm looking for a solution which lets me do this by using the toolbox or by using Java from Matlab.

¿Fue útil?

Solución

Here's what I have used. In Matlab this works.

import java.sql.*;

ConnD = DriverManager.getConnection(...
'jdbc:mysql://localhost/?user=urname&password=urpassword');

sD=ConnD.createStatement();
Result=sD.executeUpdate('CREATE DATABASE urdatabasename');
sD.close();
ConnD.close();

Mind you, this doesn't include error handling and checks. Make sure you handle your data carefully.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top