문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top