當前位置: 首頁>>代碼示例>>Java>>正文


Java SQLException.getMessage方法代碼示例

本文整理匯總了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);
    }

}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:35,代碼來源:JobStoreSupport.java

示例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);
    }
}
 
開發者ID:mhewedy,項目名稱:spwrap,代碼行數:19,代碼來源:DbUtilsResultSetAutoMapper.java

示例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;
}
 
開發者ID:JuanJoseFJ,項目名稱:ProyectoPacientes,代碼行數:31,代碼來源:MysqlDataSource.java

示例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;		
}
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:19,代碼來源:DbPreparedStatement.java

示例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;
            }
        }
    }
}
 
開發者ID:JuanJoseFJ,項目名稱:ProyectoPacientes,代碼行數:27,代碼來源:ResultSetRegressionTest.java

示例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());
	}
}
 
開發者ID:HPI-Information-Systems,項目名稱:AdvancedDataProfilingSeminar,代碼行數:27,代碼來源:SqlInputIterator.java

示例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);
	}
}
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:12,代碼來源:DbPreparedStatement.java

示例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
}
 
開發者ID:olavloite,項目名稱:spanner-jdbc,代碼行數:14,代碼來源:AbstractCloudSpannerConnection.java

示例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) {
        }
    }
}
 
開發者ID:Julien35,項目名稱:dev-courses,代碼行數:33,代碼來源:TestOdbcTypes.java

示例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);
		}

	}
 
開發者ID:igniterealtime,項目名稱:ofmeet-openfire-plugin,代碼行數:38,代碼來源:SipAccountDAO.java

示例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);
    }
}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:16,代碼來源:JobStoreSupport.java

示例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) {
        }
    }
}
 
開發者ID:Julien35,項目名稱:dev-courses,代碼行數:40,代碼來源:TestOdbcTypes.java

示例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) {
        }
    }
}
 
開發者ID:Julien35,項目名稱:dev-courses,代碼行數:30,代碼來源:TestOdbcTypes.java

示例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);
}
 
開發者ID:Jugendhackt,項目名稱:OpenVertretung,代碼行數:12,代碼來源:LoadBalancedConnectionProxy.java


注:本文中的java.sql.SQLException.getMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。