exception

How to insert a row and ignore only UNIQUE contraint errors, without using SELECT

感情迁移 提交于 2020-01-16 18:22:12
问题 I have a table with a column that must have UNIQUE values (but it could be also a multiple-column UNIQUE index, the problem is the same). In my PHP script I have to insert a row in that table. I'm searching for a way, not MySQL-specific, to exit the PHP script if there's a problem, and the problem is not a violation of a UNIQUE constraint. To make things more easy I don't want to use a SELECT query before :D Currently I'm doing something like this: try { $stmt = $dbh->prepare($someinsertquery

How to insert a row and ignore only UNIQUE contraint errors, without using SELECT

可紊 提交于 2020-01-16 18:22:10
问题 I have a table with a column that must have UNIQUE values (but it could be also a multiple-column UNIQUE index, the problem is the same). In my PHP script I have to insert a row in that table. I'm searching for a way, not MySQL-specific, to exit the PHP script if there's a problem, and the problem is not a violation of a UNIQUE constraint. To make things more easy I don't want to use a SELECT query before :D Currently I'm doing something like this: try { $stmt = $dbh->prepare($someinsertquery

Tomcat: trace all (even catched) exceptions

China☆狼群 提交于 2020-01-16 18:14:47
问题 is it possible to trace all exceptions in Tomcat server (or, in general, JVM)? Thanks for all! P.S. I need it because exception occurs in org.primefaces.application.PrimeResourceHandler.handleResourceRequest() and a trivial message is printed (line 79) 回答1: Sure. Start tomcat using that: ./catalina jpda start And then connect using the eclipse debugger, as described here: http://wiki.apache.org/tomcat/FAQ/Developing#Q1 When for example Eclipse is connected, go to the Breakpoints panel, there

Tomcat: trace all (even catched) exceptions

不羁岁月 提交于 2020-01-16 18:14:08
问题 is it possible to trace all exceptions in Tomcat server (or, in general, JVM)? Thanks for all! P.S. I need it because exception occurs in org.primefaces.application.PrimeResourceHandler.handleResourceRequest() and a trivial message is printed (line 79) 回答1: Sure. Start tomcat using that: ./catalina jpda start And then connect using the eclipse debugger, as described here: http://wiki.apache.org/tomcat/FAQ/Developing#Q1 When for example Eclipse is connected, go to the Breakpoints panel, there

How does one correctly create and access a KeyStore in java to store an encryption key?

丶灬走出姿态 提交于 2020-01-16 14:32:10
问题 I've been mixing and matching code, trying to learn by example for using KeyStores. I have this createKeyStore method: private static KeyStore createKeyStore(String fileName, String pw) throws Exception { File file = new File(fileName); final KeyStore keyStore = KeyStore.getInstance("JCEKS"); if (file.exists()) { // .keystore file already exists => load it keyStore.load(new FileInputStream(file), pw.toCharArray()); } else { // .keystore file not created yet => create it keyStore.load(null,

Android application is not Runnning Error:Resources$NotFoundException: Resource ID #0x7f030004

ぃ、小莉子 提交于 2020-01-16 08:59:47
问题 I'm stuck between some unusual problem.My app was running properly but I did some changes and switch the workspace. Now if I run my project the application closes with " Force to close " dialog. I couldn't understand my log cat error detail. Edit: R File: public static final int main=0x7f030004; Java Code: public class AlphaKidsActivity extends Activity implements OnClickListener{ MediaPlayer mp1; MediaPlayer mp2; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

Exception not caught after signal

痴心易碎 提交于 2020-01-16 08:20:30
问题 I try to catch a termination signal to my code to write a restart file before exiting. My solution is based on this answer. #include <exception> #include <csignal> #include <iostream> class InterruptException : public std::exception { public: InterruptException(int _s) : signal_(_s) { } int signal() const noexcept { return this->signal_; } private: int signal_; }; /// method to throw exception at signal interrupt void sig_to_exception(int s) { throw InterruptException(s); } int main() { //

Serialize only those properties of an Interface that exist in the Interface

自古美人都是妖i 提交于 2020-01-16 08:19:31
问题 So I'm trying to serialize only those properties of an interface that exist in the interface, not the underlying type itself. To that end, by following this, I've written the following code: public static IEnumerable<T> ToInterfacedObjects<T>(this IEnumerable<T> data) where T : class { var list = new List<T>(); var properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (var datum in data) { var moq = new Mock<T>(); foreach (var propertyInfo in properties) {

Python unittest assertraises error

不问归期 提交于 2020-01-16 05:10:27
问题 I had this weird trouble running my unittest in Python: I used assertRaises, and running the unittest raised the correct exception, but the test still failed. Ok I cannot really explain it, please see the traceback for yourself: Error Traceback (most recent call last): File "/Users/chianti/PycharmProjects/Programming_Project/Part1and4/Part1and4Test.py", line 32, in test_non_alpha_name self.assertRaises(RestNameContainNonAlphaError, RestaurantName(self.non_alpha_name)) File "/Users/chianti

session.invalidate() IllegalStateException

落花浮王杯 提交于 2020-01-16 03:25:10
问题 I'm trying to invalidate a session. When I call: session.invalidate() it throws java.lang.IllegalStateException: getLastAccessedTime: Session already invalidated Any idea why? I can see the session and it's values just before the invalidate line. 回答1: You can use an HttpSessionListener to understand where and when the Session is timing-out or getting invalidated before you call the invalidate yourself. 来源: https://stackoverflow.com/questions/6055187/session-invalidate-illegalstateexception