1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.webphotos.tools;
17
18 import java.sql.*;
19
20
21
22
23
24 public class XMLExport {
25
26
27
28
29
30
31
32
33
34
35 public static void main(String a[]) {
36 Connection conn = null;
37 Statement st1;
38
39 try {
40 Class.forName("com.mysql.jdbc.Driver").newInstance();
41 System.out.println("driver carregado");
42 conn = DriverManager.getConnection("jdbc:mysql://192.168.100.1/saopaulo", "root", "");
43 } catch (Exception e) {
44 System.out.println("-------------------------------------------------------------------");
45 System.out.println("BancoImagem.erro: nao foi possivel carregar o driver do banco de dados");
46 System.out.println(" erro: " + e.toString());
47 System.out.println("-------------------------------------------------------------------");
48 System.exit(0);
49 }
50
51
52
53
54 try {
55 String sql1 = "select albumID, nmCategoria, nmAlbum, descricao, DATE_FORMAT(dtInsercao,'%d/%m/%y') as dtInsercao from albuns left join categorias using (categoriaID) limit 10";
56 st1 = conn.createStatement();
57 ResultSet rs1 = st1.executeQuery(sql1);
58 while (rs1.next()) {
59 System.out.println(rs1.getString("descricao"));
60 }
61 rs1.close();
62 st1.close();
63 conn.close();
64
65 } catch (Exception ex) {
66 }
67
68
69 }
70 }