Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************ПОДКЛЮЧАЕМСЯ К БАЗЕ ДАННЫХ*********************/
- //JDBC URL, username and password of MySQL server
- private static final String url = "jdbc:mysql:";
- private static final String user = "";
- private static final String password = "";
- /**************************КОНЕЦ***************************/
- // --------ДОБАВЛЕНИЕ ДАННЫХ--------
- try{
- String query = " INSERT INTO coordinates_centre (id, la, lon"// добавляем данные в таблицу coordinates_centre
- +", ti, sp)n"
- + "VALUES('"+id+"', '"+la+"', '"+lo+"', '"+ti+"', '"+sp+"');";
- // opening database connection to MySQL server
- con = DriverManager.getConnection(url, user, password);
- // getting Statement object to execute query
- stmt = con.createStatement();
- // executing SELECT query
- rs = stmt.executeUpdate(query);
- } catch (SQLException sqlEx) {
- sqlEx.printStackTrace();
- } finally {
- //close connection ,stmt and resultset here
- try { con.close(); } catch(SQLException se) { /*can't do anything */ }
- try { stmt.close(); } catch(SQLException se) { /*can't do anything */ }
- }
- // --------КОНЕЦ--------
- CLASSPATH=/home/chubatiy/my/<ИМЯ>.jar:/home/chubatiy/my/libs/ java org.me.Start
Add Comment
Please, Sign In to add comment