小编Xpe*_*z X的帖子

在MySQL中查找AUTO_INCREMENT列的下一个值

我正在使用MySQL.我想在不输入新记录的情况下检索AUTO_INCREMENT列将采用的下一个值.

create table ABC(id int(10) NOT NULL AUTO_INCREMENT,name char(10));
Run Code Online (Sandbox Code Playgroud)

在oracle中我会使用sequencename.nextval();但是我在MySQL中使用了什么?

这是我为什么不能

select max(id) from ABC;
Run Code Online (Sandbox Code Playgroud)

假设我有一个id = 2的条目.现在列id将下一个值设为3.在创建id = 3的记录之前,如果我删除id = 2的记录.我提到的查询的答案是2.但我想要实际值3,auto_increment列无论如何都要采用.

mysql auto-increment next

8
推荐指数
1
解决办法
1万
查看次数

JFrame使用null布局非常小

嗨,我正在编写一个简单的程序来显示一个框架.然而,当我输入setLayout(null)时,框架变得非常小; 但如果我忽略这个命令,按钮总是在顶部中心可以有人指出我的错误吗?

import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

class theframe {

    private static void create() {
        JFrame frame = new JFrame("FrameDemo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Insets insets = frame.getInsets();
        frame.setSize(500 + insets.left + insets.right, 350 + insets.top + insets.bottom);
        add(frame.getContentPane()); //my function add
        frame.pack();
        frame.setVisible(true);
    }

    public static void add(Container pane) {
        pane.setLayout(null);
        Insets insets = pane.getInsets();

        JPanel p1 = new JPanel();
        p1.setPreferredSize(new Dimension(500, 350));

        JButton b1 = new JButton("one");
        Dimension size = b1.getPreferredSize();
        b1.setBounds(25 + insets.left, 5 + insets.top, size.width, …
Run Code Online (Sandbox Code Playgroud)

java swing jpanel jframe

1
推荐指数
2
解决办法
2039
查看次数

运算符重载>>和私有成员

请在标记为重复之前阅读

我正在重载运算符>>和<<用于读取具有实部r和虚部i的复数;

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class complex
{
    int r,i;
public:
complex()
{ i=r=0;}
friend istream& operator>>(istream&, complex&);
friend ostream& operator<<(ostream&,complex&);
};
istream& operator>>(ifstream &din, complex &x)
{
    din>>x.r;
    din>>x.i;
    return din;
}
ostream& operator<<(ostream &dout, complex &x)
{
dout<<x.r<<x.i;
return dout;
}
void main()
{
clrscr();
complex x;
cin>>x;
cout<<x;

}
Run Code Online (Sandbox Code Playgroud)

错误是代码部分无法访问r和i

din>>x.r; din>>x.i;

错误是r和i是私有的,因此无法访问不是正常的朋友功能能够访问私有变量.为什么只有>>失败?

注意:<<运算符工作正常.只有>>失败

c++ operator-overloading cin private-members friend-function

0
推荐指数
1
解决办法
3332
查看次数