Permalink
Cannot retrieve contributors at this time
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?
2017-CSE-Senior-Project-Team-2/src/database/MySQLAccess.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
33 lines (26 sloc)
1.02 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |