本文整理汇总了Java中java.sql.SQLException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java SQLException.getMessage方法的具体用法?Java SQLException.getMessage怎么用?Java SQLException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.SQLException
的用法示例。
在下文中一共展示了SQLException.getMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pauseAll
import java.sql.SQLException; //导入方法依赖的package包/类
/**
* <p>
* Pause all triggers - equivalent of calling <code>pauseTriggerGroup(group)</code>
* on every group.
* </p>
*
* <p>
* When <code>resumeAll()</code> is called (to un-pause), trigger misfire
* instructions WILL be applied.
* </p>
*
* @see #resumeAll(SchedulingContext)
* @see #pauseTriggerGroup(SchedulingContext, String)
*/
public void pauseAll(Connection conn, SchedulingContext ctxt)
throws JobPersistenceException {
String[] names = getTriggerGroupNames(conn, ctxt);
for (int i = 0; i < names.length; i++) {
pauseTriggerGroup(conn, ctxt, names[i]);
}
try {
if (!getDelegate().isTriggerGroupPaused(conn, ALL_GROUPS_PAUSED)) {
getDelegate().insertPausedTriggerGroup(conn, ALL_GROUPS_PAUSED);
}
} catch (SQLException e) {
throw new JobPersistenceException(
"Couldn't pause all trigger groups: " + e.getMessage(), e);
}
}
示例2: map
import java.sql.SQLException; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public T map(Result<?> result) {
ResultSet rs = (ResultSet) result.wrappedObject();
try {
if (rs.getMetaData().getColumnCount() == 1){
// same code as org.apache.commons.dbutils.handlers.ScalarHandler
// (cannot reuse the object as it calls rs.next())
return (T) rs.getObject(1);
}else {
return beanProcessor.toBean(rs, getType());
}
} catch (SQLException e) {
throw new CallException(e.getMessage(), e);
}
}
示例3: Load
import java.sql.SQLException; //导入方法依赖的package包/类
public static boolean Load()
{
if(!dailylist.isEmpty())
return false;
ResultSet resultSet = ConnectionClass.selectQuery("select * from dailywork;");
try{
while(resultSet.next()){
dailylist.add(new DailyTask(Integer.parseInt(resultSet.getObject(1).toString()),
resultSet.getObject(2).toString(),
resultSet.getObject(3).toString(),
resultSet.getString(4),
resultSet.getString(5)));
}
System.out.println("loaded with size of " + dailylist.size());
}catch(SQLException e){
e.getMessage();
}
return true;
}
开发者ID:HamzaYasin1,项目名称:HR-Management-System-in-Java-using-swing-framework,代码行数:21,代码来源:DailyTaskHandling.java
示例4: getReference
import java.sql.SQLException; //导入方法依赖的package包/类
/**
* Required method to support this class as a <CODE>Referenceable</CODE>.
*
* @return a Reference to this data source
*
* @throws NamingException
* if a JNDI error occurs
*/
public Reference getReference() throws NamingException {
String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
Reference ref = new Reference(getClass().getName(), factoryName, null);
ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY, getUser()));
ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, this.password));
ref.add(new StringRefAddr("serverName", getServerName()));
ref.add(new StringRefAddr("port", "" + getPort()));
ref.add(new StringRefAddr("databaseName", getDatabaseName()));
ref.add(new StringRefAddr("url", getUrl()));
ref.add(new StringRefAddr("explicitUrl", String.valueOf(this.explicitUrl)));
//
// Now store all of the 'non-standard' properties...
//
try {
storeToRef(ref);
} catch (SQLException sqlEx) {
throw new NamingException(sqlEx.getMessage());
}
return ref;
}
示例5: execute
import java.sql.SQLException; //导入方法依赖的package包/类
private int execute()
{
if(m_PreparedStatement != null)
{
try
{
boolean b = m_PreparedStatement.execute();
if(b)
return 1;
}
catch (SQLException e)
{
Log.logCritical("SQL execute error: "+e.getMessage());
throw new RuntimeException("SQL execute error: "+e.getMessage(),e);
}
}
return -1;
}
示例6: testFixForBug1592
import java.sql.SQLException; //导入方法依赖的package包/类
/**
* Checks fix for BUG#1592 -- cross-database updatable result sets are not
* checked for updatability correctly.
*
* @throws Exception
* if the test fails.
*/
public void testFixForBug1592() throws Exception {
if (versionMeetsMinimum(4, 1)) {
Statement updatableStmt = this.conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
try {
updatableStmt.execute("SELECT * FROM mysql.user");
this.rs = updatableStmt.getResultSet();
} catch (SQLException sqlEx) {
String message = sqlEx.getMessage();
if ((message != null) && (message.indexOf("denied") != -1)) {
System.err.println("WARN: Can't complete testFixForBug1592(), access to 'mysql' database not allowed");
} else {
throw sqlEx;
}
}
}
}
示例7: next
import java.sql.SQLException; //导入方法依赖的package包/类
@Override
public boolean next() throws InputIterationException {
try {
boolean hasNext = this.resultSet.next();
if (hasNext) {
int numColumns = this.resultSet.getMetaData().getColumnCount();
this.record = new ArrayList<>(numColumns);
for (int columnIndex = 1; columnIndex <= numColumns; columnIndex++) {
String value = this.resultSet.getString(columnIndex);
// Replace line breaks with the zero-character, because these line breaks would otherwise split values when later written to plane-text buckets
if (value != null)
value = value.replaceAll("\n", "\0");
this.record.add(value);
}
}
return hasNext;
}
catch (SQLException e) {
e.printStackTrace();
throw new InputIterationException(e.getMessage());
}
}
示例8: setColParam
import java.sql.SQLException; //导入方法依赖的package包/类
public void setColParam(int nCol, int nValue)
{
try
{
m_PreparedStatement.setInt(nCol+1, nValue);
}
catch (SQLException e)
{
throw new RuntimeException("Could not set columnn "+String.valueOf(nCol)+" to value '"+String.valueOf(nValue)+"': "+e.getMessage(),e);
}
}
示例9: setClientInfo
import java.sql.SQLException; //导入方法依赖的package包/类
@Override
public void setClientInfo(Properties properties) throws SQLClientInfoException
{
try
{
checkClosed();
}
catch (SQLException e)
{
throw new SQLClientInfoException(e.getMessage(), Collections.emptyMap());
}
// silently ignore
}
示例10: testSecIntervalSimpleRead
import java.sql.SQLException; //导入方法依赖的package包/类
public void testSecIntervalSimpleRead() {
/* Since our client does not support the INTERVAL precision
* constraints, the returned value will always be toString()'d to
* precision of microseconds. */
ResultSet rs = null;
Statement st = null;
try {
st = netConn.createStatement();
rs = st.executeQuery("SELECT * FROM alltypes WHERE id in (1, 2)");
assertTrue("Got no rows with id in (1, 2)", rs.next());
assertEquals("1000.345000", rs.getString("sival"));
assertTrue("Got only one row with id in (1, 2)", rs.next());
// Can't test the class, because jdbc:odbc or the driver returns
// a String for getObject() for interval values.
assertFalse("Got too many rows with id in (1, 2)", rs.next());
} catch (SQLException se) {
junit.framework.AssertionFailedError ase
= new junit.framework.AssertionFailedError(se.getMessage());
ase.initCause(se);
throw ase;
} finally {
try {
if (rs != null) {
rs.close();
}
if (st != null) {
st.close();
}
} catch(Exception e) {
}
}
}
示例11: update
import java.sql.SQLException; //导入方法依赖的package包/类
public static void update(SipAccount sipAccount) throws SQLException {
String sql = "UPDATE ofSipUser SET sipusername = ?, sipauthuser = ?, sipdisplayname = ?, sippassword = ?, sipserver = ?, enabled = ?, status = ?, stunserver = ?, stunport = ?, usestun = ?, voicemail= ?, outboundproxy = ?, promptCredentials = ? "
+ " WHERE username = ?";
Connection con = null;
PreparedStatement psmt = null;
try {
con = DbConnectionManager.getConnection();
psmt = con.prepareStatement(sql);
psmt.setString(1, sipAccount.getSipUsername());
psmt.setString(2, sipAccount.getAuthUsername());
psmt.setString(3, sipAccount.getDisplayName());
psmt.setString(4, sipAccount.getPassword());
psmt.setString(5, sipAccount.getServer());
psmt.setInt(6, sipAccount.isEnabled() ? 1 : 0);
psmt.setString(7, sipAccount.getStatus().name());
psmt.setString(8, sipAccount.getStunServer());
psmt.setString(9, sipAccount.getStunPort());
psmt.setInt(10, sipAccount.isUseStun() ? 1 : 0);
psmt.setString(11, sipAccount.getVoiceMailNumber());
psmt.setString(12, sipAccount.getOutboundproxy());
psmt.setInt(13, sipAccount.isPromptCredentials() ? 1 : 0);
psmt.setString(14, sipAccount.getUsername());
psmt.executeUpdate();
} catch (SQLException e) {
Log.error(e.getMessage(), e);
throw new SQLException(e.getMessage());
} finally {
DbConnectionManager.closeConnection(psmt, con);
}
}
示例12: triggerExists
import java.sql.SQLException; //导入方法依赖的package包/类
/**
* <p>
* Check existence of a given trigger.
* </p>
*/
protected boolean triggerExists(Connection conn, String triggerName,
String groupName) throws JobPersistenceException {
try {
return getDelegate().triggerExists(conn, triggerName, groupName);
} catch (SQLException e) {
throw new JobPersistenceException(
"Couldn't determine trigger existence (" + groupName + "."
+ triggerName + "): " + e.getMessage(), e);
}
}
示例13: testBooleanComplex
import java.sql.SQLException; //导入方法依赖的package包/类
public void testBooleanComplex() {
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = netConn.prepareStatement(
"INSERT INTO alltypes(id, b) VALUES(?, ?)");
ps.setInt(1, 3);
ps.setBoolean(2, false);
assertEquals(1, ps.executeUpdate());
ps.setInt(1, 4);
assertEquals(1, ps.executeUpdate());
ps.close();
netConn.commit();
ps = netConn.prepareStatement(
"SELECT * FROM alltypes WHERE b = ?");
ps.setBoolean(1, false);
rs = ps.executeQuery();
assertTrue("Got no rows with b = false", rs.next());
assertEquals(Boolean.class, rs.getObject("b").getClass());
assertTrue("Got only one row with b = false", rs.next());
assertEquals(false, rs.getBoolean("b"));
assertFalse("Got too many rows with b = false", rs.next());
} catch (SQLException se) {
junit.framework.AssertionFailedError ase
= new junit.framework.AssertionFailedError(se.getMessage());
ase.initCause(se);
throw ase;
} finally {
try {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
} catch(Exception e) {
}
}
}
示例14: testDerivedStringSimpleRead
import java.sql.SQLException; //导入方法依赖的package包/类
public void testDerivedStringSimpleRead() {
ResultSet rs = null;
Statement st = null;
try {
st = netConn.createStatement();
rs = st.executeQuery("SELECT i, cv || 'appendage' app, 4\n"
+ "FROM alltypes WHERE id in (1, 2)");
assertTrue("Got no rows with id in (1, 2)", rs.next());
assertEquals(String.class, rs.getObject("app").getClass());
assertTrue("Got only one row with id in (1, 2)", rs.next());
assertEquals("cdappendage", rs.getString("app"));
assertFalse("Got too many rows with id in (1, 2)", rs.next());
} catch (SQLException se) {
junit.framework.AssertionFailedError ase
= new junit.framework.AssertionFailedError(se.getMessage());
ase.initCause(se);
throw ase;
} finally {
try {
if (rs != null) {
rs.close();
}
if (st != null) {
st.close();
}
} catch(Exception e) {
}
}
}
示例15: invoke
import java.sql.SQLException; //导入方法依赖的package包/类
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
SQLException exceptionToThrow = SQLError.createSQLException(Messages.getString("LoadBalancedConnectionProxy.unusableConnection"),
SQLError.SQL_STATE_INVALID_TRANSACTION_STATE, MysqlErrorNumbers.ERROR_CODE_NULL_LOAD_BALANCED_CONNECTION, true, null);
Class<?>[] declaredException = method.getExceptionTypes();
for (Class<?> declEx : declaredException) {
if (declEx.isAssignableFrom(exceptionToThrow.getClass())) {
throw exceptionToThrow;
}
}
throw new IllegalStateException(exceptionToThrow.getMessage(), exceptionToThrow);
}