1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| host = 'localhost';
% Database Username/Password
user = 'root';
password = '';
% Database Name
dbName = 'sancella';
% JDBC Parameters
jdbcString = sprintf('jdbc:mysql://%s/%s', host, dbName);
jdbcDriver = 'com.mysql.jdbc.Driver';
% Set this to the path to your MySQL Connector/J JAR
javaaddpath('C:\MATLAB7\work\mysql-connector-java-5.1.10-bin.jar');
% Create the database connection object
dbConn = database(dbName, user , password, jdbcDriver, jdbcString);
% Check to make sure that we successfully connected
if isconnection(dbConn)
% Fetch the symbol, market cap, and last close for the 10 largest
% market cap ETFs
c=get(handles.edit3,'String');
result2 = get(fetch(exec(dbConn, 'insert into machine (puissance) values (c);')), 'Data');
set(handles.uitable3,'Data',result2);
disp(result2);
% If the connection failed, print the error message
else
disp(sprintf('Connection failed: %s', dbConn.Message));
end
% Close the connection so we don't run out of MySQL thread
close(dbConn); |
Partager