sql - ORA-29532: Java call terminated by uncaught Java exception- 2005-2008 migration error -
i using c# application use both oracle , sql 2005 db connection. migrating our sql server 2005 sql 2008. when try import table sql database using dot net application getting following error.
java call terminated uncaught java exception: java.util.missingresourceexception: can't find bundle base name com.microsoft.sqlserver.jdbc.sqlserverresource, locale en_us ora-29532: java call terminated uncaught java exception: java.util.missingresourceexception: can't find bundle base name com.microsoft.sqlserver.jdbc.sqlserverresource, locale en_us ora-06512: @ "intpl.datasync_util", line 8 ora-06512: @ line 1
[last_saved_err]
during upgrade checked following path reportdbmetadatautil.java:
string password) throws classnotfoundexception, sqlexception { connection conn = null; switch (dbtype) //m.c { case db_oracle: conn =getremoteoracledbconnection (dburl, user, password); break; case db_sql_server: class.forname("com.microsoft.sqlserver.jdbc.sqlserverdriver"); //sql server 2005 //class.forname("com.microsoft.jdbc.sqlserver.sqlserverdriver"); //sql server 2000 conn =drivermanager.getconnection(dburl, user, password); break; } return conn; }
kindly give me suggestion, or ideas of references fix issue.
i'd start writing idiomatic jdbc. it's interface-based api that's supposed free writing kind of stuff posted.
you know you're doing wrong moment see code checks if it's oracle or sql server.
here's example:
package persistence; import java.sql.*; import java.util.*; /** * util.databaseutils * user: michael * date: aug 17, 2010 * time: 7:58:02 pm */ public class databaseutils { /* private static final string default_driver = "oracle.jdbc.driver.oracledriver"; private static final string default_url = "jdbc:oracle:thin:@host:1521:database"; private static final string default_username = "username"; private static final string default_password = "password"; */ /* private static final string default_driver = "org.postgresql.driver"; private static final string default_url = "jdbc:postgresql://localhost:5432/party"; private static final string default_username = "pgsuper"; private static final string default_password = "pgsuper"; */ private static final string default_driver = "com.mysql.jdbc.driver"; private static final string default_url = "jdbc:mysql://localhost:3306/party"; private static final string default_username = "party"; private static final string default_password = "party"; public static void main(string[] args) { long begtime = system.currenttimemillis(); string driver = ((args.length > 0) ? args[0] : default_driver); string url = ((args.length > 1) ? args[1] : default_url); string username = ((args.length > 2) ? args[2] : default_username); string password = ((args.length > 3) ? args[3] : default_password); connection connection = null; try { connection = createconnection(driver, url, username, password); databasemetadata meta = connection.getmetadata(); system.out.println(meta.getdatabaseproductname()); system.out.println(meta.getdatabaseproductversion()); string sqlquery = "select person_id, first_name, last_name person order last_name"; system.out.println("before insert: " + query(connection, sqlquery, collections.empty_list)); connection.setautocommit(false); string sqlupdate = "insert person(first_name, last_name) values(?,?)"; list parameters = arrays.aslist("foo", "bar"); int numrowsupdated = update(connection, sqlupdate, parameters); connection.commit(); system.out.println("# rows inserted: " + numrowsupdated); system.out.println("after insert: " + query(connection, sqlquery, collections.empty_list)); } catch (exception e) { rollback(connection); e.printstacktrace(); } { close(connection); long endtime = system.currenttimemillis(); system.out.println("wall time: " + (endtime - begtime) + " ms"); } } public static connection createconnection(string driver, string url, string username, string password) throws classnotfoundexception, sqlexception { class.forname(driver); if ((username == null) || (password == null) || (username.trim().length() == 0) || (password.trim().length() == 0)) { return drivermanager.getconnection(url); } else { return drivermanager.getconnection(url, username, password); } } public static void close(connection connection) { try { if (connection != null) { connection.close(); } } catch (sqlexception e) { e.printstacktrace(); } } public static void close(statement st) { try { if (st != null) { st.close(); } } catch (sqlexception e) { e.printstacktrace(); } } public static void close(resultset rs) { try { if (rs != null) { rs.close(); } } catch (sqlexception e) { e.printstacktrace(); } } public static void rollback(connection connection) { try { if (connection != null) { connection.rollback(); } } catch (sqlexception e) { e.printstacktrace(); } } public static list<map<string, object>> map(resultset rs) throws sqlexception { list<map<string, object>> results = new arraylist<map<string, object>>(); try { if (rs != null) { resultsetmetadata meta = rs.getmetadata(); int numcolumns = meta.getcolumncount(); while (rs.next()) { map<string, object> row = new hashmap<string, object>(); (int = 1; <= numcolumns; ++i) { string name = meta.getcolumnname(i); object value = rs.getobject(i); row.put(name, value); } results.add(row); } } } { close(rs); } return results; } public static list<map<string, object>> query(connection connection, string sql, list<object> parameters) throws sqlexception { list<map<string, object>> results = null; preparedstatement ps = null; resultset rs = null; try { ps = connection.preparestatement(sql); int = 0; (object parameter : parameters) { ps.setobject(++i, parameter); } rs = ps.executequery(); results = map(rs); } { close(rs); close(ps); } return results; } public static int update(connection connection, string sql, list<object> parameters) throws sqlexception { int numrowsupdated = 0; preparedstatement ps = null; try { ps = connection.preparestatement(sql); int = 0; (object parameter : parameters) { ps.setobject(++i, parameter); } numrowsupdated = ps.executeupdate(); } { close(ps); } return numrowsupdated; } }
Comments
Post a Comment