Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package servletsql;
- import java.sql.*;
- import java.io.*;
- import java.lang.*;
- /**
- *
- * @author Gulsort
- */
- public class Main {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) throws Exception {
- Connection conn = getHSQLConnection();
- Statement st = conn.createStatement();
- //st.executeUpdate("create table survey (id int,name varchar(30));");
- st.executeUpdate("DELETE FROM testtabel WHERE DATA1 = 24");
- st.executeUpdate("insert into testtabel (DATA1, DATA2) values (24,'pis i låget')");
- st = conn.createStatement();
- ResultSet rs = st.executeQuery("SELECT * FROM testtabel where id = 1");
- ResultSetMetaData rsMetaData = rs.getMetaData();
- int numberOfColumns = rsMetaData.getColumnCount();
- System.out.println("Antallet af kolonner er = " + numberOfColumns);
- while (rs.next()) {
- String hvadmonderståridata2 = rs.getNString("DATA2");
- System.out.println(hvadmonderståridata2);
- try {
- Runtime rt=Runtime.getRuntime();
- rt.exec("cmd.exe /C start C:\\xmldump.bat");
- System.out.println("Dump made!");
- }
- catch (Exception u)
- {
- System.out.println("Something went horribly wrong!!!");
- }
- /* Alt muligt forsøgskode - kan faktisk bare slettes xD
- rt.exec("cmd.exe");
- rt.exec("cmd.exe /C start C:\\wamp\\bin\\mysql\\mysql5.1.33\\bin\\mysqldump.exe TEST testtabel -u root -x > C:\\sqludtræk.xml");
- C:\wamp\bin\mysql\mysql5.1.33\bin\mysqldump.exe TEST testtabel -u root -x
- Process p = Runtime.getRuntime().exec("c:\myprogram.exe");
- Process p = Runtime.getRuntime().exec("C:\\wamp\\bin\\mysql\\mysql5.1.33\\bin\\mysqldump.exe TEST testtabel -u root -x > C:\\Documents and Settings\\Gulsort\\My Documents\\NetBeansProjects\\ServletSQL\\sqludtræk.xml");
- String temp = " ";
- FileWriter xmlting = new FileWriter("sqludtræk.xml");
- PrintWriter skriv = new PrintWriter(xmlting);
- skriv.println("" + temp);
- skriv.close();
- */
- }
- rs.close();
- st.close();
- conn.close();
- }
- private static Connection getHSQLConnection() throws Exception {
- Class.forName("com.mysql.jdbc.Driver");
- String url = "jdbc:mysql://localhost/TEST";
- return DriverManager.getConnection(url, "root", "");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement