benhaze
Mitglied Platinum
schau dir doch mal DOM4J an, um z.B XML-Dateien zu erstellen/lesen/ändern.
http://www.dom4j.org/dom4j-1.6.1/guide.html
http://www.dom4j.org/dom4j-1.6.1/guide.html
Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
<project name="ProfessorenInformationsSystem" default="compile" basedir=".">
<target name="prepare">
<mkdir dir="build"/>
</target>
<target name="clean" description="Clean up">
<delete dir="build"/>
<delete file="lehrende.xml"/>
</target>
<target name="compile" depends="prepare" description="Compile">
<javac srcdir="src" destdir="build"/>
</target>
<target name="run" description="Run program">
<java classname="createXML" classpath="jdbc" fork="true"/>
</target>
</project>
<target name="run" description="Run program">
<java classname="createXML" fork="true">
<classpath>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
</java>
</target>
java.lang.NoClassDefFoundError: createXML
Caused by: java.lang.ClassNotFoundException: createXML
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: createXML. Program will exit.
Exception in thread "main"
Java Result: 1
import java.sql.*;
import java.io.*;
public class createXML {
public static void main(String[] args)throws Exception {
Connection con = null;
try {
String url = "jdbc:mysql://localhost/hsnr";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String password = "jinzhosse";
Class.forName(driver);
con = DriverManager.getConnection(url, user, password);
Statement stmt = con.createStatement();
String sql = "Select* from dozenten inner join lehrgebiete on dozenten.lid = lehrgebiete.lid";
ResultSet rs = stmt.executeQuery(sql);
BufferedWriter bw = new BufferedWriter (new FileWriter("lehrende.xml"));
bw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\r");
bw.write("<lehrende>");
while (rs.next()){
bw.write("<person>");
bw.write("<titel>");
String titel = rs.getString("Titel");
bw.write(titel);
bw.write("</titel>");
bw.write("<vorname>");
String vorname = rs.getString("Vorname");
bw.write(vorname);
bw.write("</vorname>");
bw.write("<nachname>");
String nachname = rs.getString("Nachname");
bw.write(nachname);
bw.write("</nachname>");
bw.write("<lehrgebiet>");
String lehrgebiet = rs.getString("Lehrgebiet");
bw.write(lehrgebiet);
bw.write("</lehrgebiet>");
bw.write("<website>");
String website = rs.getString("Website");
bw.write(website);
bw.write("</website>");
bw.write("<room>");
String room = rs.getString("Buero");
bw.write(room);
bw.write("</room>");
bw.write("<email>");
String email = rs.getString("Email");
bw.write(email);
bw.write("</email>");
bw.write("<tel>");
String telefon = rs.getString("Telefon");
bw.write(telefon);
bw.write("</tel>");
bw.write("<fax>");
String fax = rs.getString("Fax");
bw.write(fax);
bw.write("</fax>");
bw.write("<img src='");
String img = rs.getString("Img");
bw.write(img);
bw.write("'/>");
bw.write("</person>\n\r");
}
bw.write("</lehrende>\n\r");
con.close();
bw.close();
rs.close();
stmt.close();
}
finally {
try {
if (con != null)
con.close();
}
catch (Exception e) {
System.err.println(e);
}
}
}
}
if rs.getString("Img") =null then doNothing und Springzumnächsten Tag..
schau dir doch mal DOM4J an, um z.B XML-Dateien zu erstellen/lesen/ändern.
http://www.dom4j.org/dom4j-1.6.1/guide.html