Project

General

Profile

« Previous | Next » 

Revision 9

code cleanup for pw handling

View differences:

DBWriter.java
48 48
        conn = openDBConnection(
49 49
		"oracle.jdbc.driver.OracleDriver",
50 50
		"jdbc:oracle:thin:@penelope.nceas.ucsb.edu:1526:DEV",
51
		"jones", "kinkaj0u");
51
		argv[2], argv[3]);
52 52

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

  
76 53
	//
77 54
	// Load the document, using the appropriate custom
78 55
	// DOM elements.
......
90 67
        root.writeXmlToDB(conn);
91 68
    }
92 69

  
93
    //
94
    // usage:  main someprops.props someplay.xml 
95
    //
96 70
    public static void main (String argv [])
97 71
    {
98 72
	try {
99
	    if (argv.length != 2) {
100
		System.err.println ("usage: java project.DBWriter "
101
		    + "someprops.props someplay.xml");
73
	    if (argv.length != 4) {
74
		System.err.println ("usage: java DBWriter "
75
		    + "DBElement.props somefile.xml username password");
102 76
		System.exit (1);
103 77
	    }
104 78

  
......
167 141
		String user, String password) 
168 142
		throws SQLException, ClassNotFoundException {
169 143
      // Load the Oracle JDBC driver
170
      Class.forName ("oracle.jdbc.driver.OracleDriver");
144
      Class.forName (dbDriver);
171 145

  
172 146
      // Connect to the database
173 147
      // You can put a database name after the @ sign in the connection URL.
174 148
      Connection conn = DriverManager.getConnection(
175
	"jdbc:oracle:thin:@penelope.nceas.ucsb.edu:1526:DEV", 
176
	"jones", "kinkaj0u");
149
	connection, user, password);
177 150
      return conn;
178 151
    }
179 152

  

Also available in: Unified diff