如何在java netbeans中使用autonumber? [英] how to use autonumber in java netbeans?

查看:80
本文介绍了如何在java netbeans中使用autonumber?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

void notrans(){
// this is my function :
try{
    
    String sql="select right(No_Trans,2) as no_akhir from jual";
    Statement stat=conn.createStatement();
    ResultSet res=stat.executeQuery(sql);
    if(res.first()==false){
        txttrans.setText("TRX0001");
    }else{ 
        res.last(); 
        int no=res.getInt(1)+1;
        String cno=String.valueOf(no);
        int pjg_cno=cno.length();
        for(int i=0;i<2-pjg_cno;i++){
           cno="00"+cno;
    }
    txttrans.setText("TRX00"+cno);
}
}catch(Exception e ){
}
}

推荐答案

像Afzaal所说,这可以在您的数据库系统中轻松设置(无论它是什么)。它是一个名为自动增量或有时AI的列的属性,如MySQL中所示。您只需单击AI(或自动递增)复选框即可,您的列现在将自动递增其ID。
Like Afzaal said, this can be easily set up in your Database system (whatever it may be). It is a property of a column called 'Auto-increment' or sometimes AI, as in MySQL. You simply click the AI (or auto-increment) checkbox and voilà, your column will now be automatically incrementing it's ID.


这篇关于如何在java netbeans中使用autonumber?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆