Guest User

Untitled

a guest
Jul 8th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. public void writeToFile() throws IOException {
  2.         Connection dbConnection = null;
  3.         PreparedStatement statement = null;
  4.  
  5.  
  6.         try {
  7.             Class.forName("com.mysql.jdbc.Driver").newInstance();
  8.             System.out.println("MYSQL:s JDBC-drivrutiner hittades.");
  9.         } catch (Exception e) {
  10.             System.err.println("MYSQL:s JDBC-drivrutiner kunde INTE hittas.");
  11.         }
  12.  
  13.         String url = "jdbc:mysql://atlantis.informatik.umu.se/svph1102_db2_vt2012";
  14.         String user = "svph1102";
  15.         String password = "qygebagaq";
  16.         try {
  17.             dbConnection = DriverManager.getConnection(url, user, password);
  18.         statement = dbConnection.prepareStatement("INSERT INTO BLA BLA");
  19.  
  20.         for (int i = 0; i < spelLista.size(); i++) {
  21.         Spel s = spelLista.get(i);
  22.         }
  23.  
  24.         } catch (SQLException ex) {
  25.             System.err.println("Ett fel har uppstått: " + ex.toString());
  26.         }
  27.     }
Add Comment
Please, Sign In to add comment