Project

General

Profile

« Previous | Next » 

Revision 8

Added by Matt Jones over 25 years ago

element insertions added to db

View differences:

DBWriter.java
38 38
public class DBWriter
39 39
{
40 40
    private XmlDocument			doc;
41
    private Connection			conn;
41
    private Connection			conn = null;
42 42

  
43 43
    // Constructer to init the class
44 44
    public DBWriter(String argv[]) 
45 45
	throws SAXException, SQLException, IOException, ClassNotFoundException {
46 46

  
47
	//
48
	// Load the document, using the appropriate custom
49
	// DOM elements.
50
	//
51
	XmlDocument	doc = createDocument (
52
		Resolver.createInputSource (new File (argv [1])),
53
		new FileInputStream (argv [0]),
54
		new ErrorPrinter ()
55
	);
56

  
57
	DBElement		root;
58

  
59
    	root = (DBElement)doc.getDocumentElement ();
60
	root.normalize ();
61
        System.out.println(root.getJunk());
62
       
47
        // Open a connection to the database
63 48
        conn = openDBConnection(
64 49
		"oracle.jdbc.driver.OracleDriver",
65 50
		"jdbc:oracle:thin:@penelope.nceas.ucsb.edu:1526:DEV",
66 51
		"jones", "kinkaj0u");
67 52

  
53
	// THIS IS TEMPORARY 
68 54
        // Prepare a statement to cleanup the emp table
55
/*
69 56
        Statement stmt = conn.createStatement ();
70 57
        try {
71 58
            	stmt.execute ("delete from xml_elements where nodeid = 1500");
72 59
        } catch (SQLException e) {
73 60
        	// Ignore an error here
74 61
        }
75
        
62
*/       
63
	// THIS IS TEMPORARY 
76 64
        // Prepare to insert new names in the Elements table
65
/*
77 66
        PreparedStatement pstmt = conn.prepareStatement(
78 67
	        "insert into xml_elements (nodeid, nodename) values (?, ?)");
79 68
        
80
        // Add an element as employee number 1500
69
        // Add an element as element number 1500
81 70
        pstmt.setInt (1, 1500);	// The first ? is for NODEID
82 71
        pstmt.setString (2, "eml-variable");// The second ? is for NODENAME
83 72
        // Do the insertion
84 73
        pstmt.execute ();
74
*/
75

  
76
	//
77
	// Load the document, using the appropriate custom
78
	// DOM elements.
79
	//
80
	XmlDocument	doc = createDocument (
81
		Resolver.createInputSource (new File (argv [1])),
82
		new FileInputStream (argv [0]),
83
		new ErrorPrinter ()
84
	);
85

  
86
	DBElement		root;
87

  
88
    	root = (DBElement)doc.getDocumentElement();
89
	root.normalize();
90
        root.writeXmlToDB(conn);
85 91
    }
86 92

  
87 93
    //

Also available in: Unified diff