Code example for PreparedStatement

Methods: executeUpdatesetBinaryStreamsetStringsetQueryTimeout

0
				File file = new File(filePath);
				FileInputStream fis = new FileInputStream(file);
				String insertLine = "insert into dishPhoto (dish, date, photo) values (?, ?, ?);";
				PreparedStatement ps = null;
				ps = con.prepareStatement(insertLine);
				ps.setString(1, dishName);
				ps.setString(2, date);
				ps.setBinaryStream(3, fis, (int)file.length());
				System.out.println(insertLine);
				ps.setQueryTimeout(5);
				ps.executeUpdate();
				System.out.println("server submit photo");
				return true; 
			} catch (SQLException e) {
				// TODO Auto-generated catch block 
				System.out.println("no connection!!!"+"submit photo");
				//error(context); 
				e.printStackTrace();
				return false; 
			} catch (FileNotFoundException e) {
Stop searching for code, let great code find you!  Add Codota to your java IDE