Skip to content
Permalink
11fe650bdc
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
33 lines (26 sloc) 1.02 KB
package database;
import java.sql.*;
public class MySQLAccess {
String[][] result = new String[20][3];
public void connectDB() throws SQLException, ClassNotFoundException {
System.getenv("VCAP_SERVICES");
Class.forName("com.mysql.jdbc.Driver");
Connection connect = DriverManager.getConnection("jdbc:mysql://us-cdbr-iron-east-04.cleardb.net/ad_15a989204c2ff8a?user=b372dfe7409692&password=74f6e317", "b372dfe7409692", "74f6e317");
Statement statement = connect.createStatement();
//PreparedStatement preparedStatement = null;
ResultSet resultSet = statement.executeQuery("SELECT * FROM devices");
while(resultSet.next()){
String deviceName = resultSet.getString("Device_Name");
String deviceDescription = resultSet.getString("Device_Description");
String hardwareType = resultSet.getString("Hardware_Model");
for(int i = 0; i<1; i++){
result[i][0] = deviceName;
result[i][1] = deviceDescription;
result[i][2] = hardwareType;
}
}
}
public String[][] getResult(){
return result;
}
}