我们从各种数据库类型(Oracle,MySQL,SQL-Server,...)中提取数据.一旦成功写入文件,我们希望将其标记为已传输,因此我们更新特定列.
我们的问题是,用户有可能在此期间更改数据但可能忘记提交.使用select for update语句阻止记录.所以它可能发生,我们将某些东西标记为已传输,而不是.
这是我们代码的摘录:
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet extractedData = stmt.executeQuery(sql);
writeDataToFile(extractedData);
extractedData.beforeFirst();
while (extractedData.next()) {
if (!extractedData.rowUpdated()) {
extractedData.updateString("COLUMNNAME", "TRANSMITTED");
// code will stop here if user has changed data but did not commit
extractedData.updateRow();
// once committed the changed data is marked as transmitted
}
}
Run Code Online (Sandbox Code Playgroud)
该方法extractedData.rowUpdated()返回false,因为从技术上讲,用户还没有更改任何内容.有没有办法不更新行并检测数据是否在此后期更改?
不幸的是,我无法更改用户用来更改数据的程序.
我试图在里面放几个组件ScrollPane.这些组件应该能够通过鼠标(单击并拖动)在此窗格中移动.它ScrollPane本身是可以平移和可缩放的.
现在,如果我选择其中一个并将其拖动到一个新位置,如果我缩小,鼠标比组件快.放大时,组件的移动速度比鼠标移动的速度快.
如果没有缩放,它会一直工作,直到我到达ScrollPane自动平移的某个位置.
它必须对确定的节点坐标做一些事情.有没有人知道我必须添加什么才能使其正常工作?
我的控制器类:
public class MainWindowController implements Initializable {
private final double SCALE_DELTA = 1.1;
private final StackPane zoomPane = new StackPane();
private Group group = new Group();
@FXML
private ScrollPane scrollPane;
@Override
public void initialize(URL url, ResourceBundle rb) {
Node node1 = new Node("Test");
Node node2 = new Node("Test2", 100, 200);
group.getChildren().addAll(node1, node2);
zoomPane.getChildren().add(group);
Group scrollContent = new Group(zoomPane);
scrollPane.setContent(scrollContent);
scrollPane.viewportBoundsProperty().addListener((ObservableValue<? extends Bounds> observable,
Bounds oldValue, Bounds newValue) -> {
zoomPane.setMinSize(newValue.getWidth(), …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个读取 wav 文件并发送输出的小程序,就好像它来自我的麦克风一样。不幸的是,我对声音 API 没有太多经验。
背景:我基本上想要实现的是一个程序,当我在语音聊天(即 Teamspeak、Ventrilo)中时会播放声音。为了让它现在工作,我必须将录音设备切换到“你听到的”,播放声音,然后切换回麦克风。该程序应模拟来自麦克风的输入。
到目前为止,我只能播放声音。我想我只需要一个不同的 SourceLine?
public class Player {
private final int BUFFER_SIZE = 128000;
private AudioInputStream audioStream;
private AudioFormat audioFormat;
private SourceDataLine sourceLine;
public void playSound(File soundFile) {
try {
audioStream = AudioSystem.getAudioInputStream(soundFile);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
audioFormat = audioStream.getFormat();
DataLine.Info infoIn = new DataLine.Info(SourceDataLine.class,
audioFormat);
try {
sourceLine = (SourceDataLine) AudioSystem.getLine(infoIn);
sourceLine.open(audioFormat);
} catch (LineUnavailableException e) {
e.printStackTrace();
System.exit(1);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
sourceLine.start();
int nBytesRead …Run Code Online (Sandbox Code Playgroud) 我现在使用Netty一段时间了,永远无法解决这个问题.可以下载四个不同的版本.其中三个正在积极开发.
3.X
4.0.x版
4.1.x版
5.x的
据我所知,3.x适用于JRE 1.5,JRE的其他所有内容都大于此.我使用的是4.0.28,因为它是稳定版和推荐版.但是其他版本的差异或目标到底是什么?
我在他们的网站上找不到任何关于此的信息.
编辑:我看到接近投票,所以我想澄清一下:我不是在寻找那些列出版本代码中所有差异的人.但4.1.x和5.x版本必须有某种目标或目的.
我猜这里做错了什么,但我无法弄清楚导致错误的原因.这是我第一次尝试自定义序列化.
我将对象存储在BLOB字段中的数据库中.在某些时候,我再次阅读它们.
这是可序列化的类:
public class Job extends Observable implements Serializable {
private static final long serialVersionUID = 7530757972497270533L;
private Path file;
private String errorText = "";
private int moduleID;
private int jobID;
private JobStatus status;
public Job(int moduleID, Path file) {
this.moduleID = moduleID;
this.file = file;
status = JobStatus.ACCEPTED;
}
public Path getFile() {
return file;
}
public void setFile(Path file) {
setChanged();
this.file = file;
notifyObservers(this);
}
public int getModuleID() {
return moduleID;
}
public void setModuleID(int moduleID) …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的一个程序中创建一个小绘图板。这是课程:
class DrawPad extends JComponent {
Image image;
Graphics2D graphics;
int currentX, currentY, oldX, oldY;
public DrawPad() {
setDoubleBuffered(false);
addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
oldX = e.getX();
oldY = e.getY();
}
});
addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(MouseEvent e) {
currentX = e.getX();
currentY = e.getY();
if (graphics != null) {
graphics.drawLine(oldX, oldY, currentX, currentY);
}
repaint();
oldX = currentX;
oldY = currentY;
}
});
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (image …Run Code Online (Sandbox Code Playgroud)