首页 \ 问答 \ java.lang.NullPointerException和ResultSet(java.lang.NullPointerException and ResultSet)

java.lang.NullPointerException和ResultSet(java.lang.NullPointerException and ResultSet)

这是我的第一篇文章,请耐心等待。 我正在研究一个java项目,它连接到一个sql数据库。 我目前要做的是当我单击一个按钮时,将在我的数据库的文本区域中显示项目的名称和具有指定ID的项目的价格。 但是,当我单击该按钮时,会出现如下错误:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at OrderFrame.waterButtonActionPerformed(OrderFrame.java:494)
at OrderFrame.access$000(OrderFrame.java:11)

这是我的waterButtonActionPerformed的代码:

private void waterButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
// TODO add your handling code here:
    try{

    String query;
    query = "SELECT itemName, itemPrice FROM item WHERE itemID = '11111'";
    String itemName = " ",itemPrice =" ";  

      ***ResultSet rs = st.executeQuery(query);***

       if(rs != null){
        while(rs.next())
        { 
         itemName = rs.getString(1);
         itemPrice = rs.getString(2);
        }
       orderTextArea.setText(itemName);
       orderTextArea.setText(itemPrice);
       }
         } catch (SQLException ex) {}
}        

第494行是具有ResultSet声明的行。 我希望有人可以帮我解决这个问题。 先谢谢你。


This is my first post so please be patient. I am working on a java project and that connects to a sql database. What I am currently trying to do is when I click a button, will display the name of the item and the price of the item with the specified ID in the text area from my database. However, when I click the button an error such as this appears:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at OrderFrame.waterButtonActionPerformed(OrderFrame.java:494)
at OrderFrame.access$000(OrderFrame.java:11)

Here is the code for my waterButtonActionPerformed:

private void waterButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
// TODO add your handling code here:
    try{

    String query;
    query = "SELECT itemName, itemPrice FROM item WHERE itemID = '11111'";
    String itemName = " ",itemPrice =" ";  

      ***ResultSet rs = st.executeQuery(query);***

       if(rs != null){
        while(rs.next())
        { 
         itemName = rs.getString(1);
         itemPrice = rs.getString(2);
        }
       orderTextArea.setText(itemName);
       orderTextArea.setText(itemPrice);
       }
         } catch (SQLException ex) {}
}        

The line 494 is the one with the declaration of the ResultSet. I am am hoping someone can help me fix this issue. Thank you in advance.


原文:https://stackoverflow.com/questions/15794369
更新时间:2024-02-21 11:02

最满意答案

Twilio开发者传道者在这里。

如果您正在寻找使用Twilio拨打电话,我建议您按照此快速入门指南使用C#拨打电话 。 它将带您了解基础知识。

为了更深入地了解一下,我将通过本教程来了解如何使用C#ASP.NET MVC构建一个单击调用系统

如果这有帮助,请告诉我。


I am able to solve the issue . As I already had

hiro usb modem h50113

so i just used AT Command

ATDT (Phone number)

here is the code :

this.sp.WriteLine("ATDT 1234567890" + System.Environment.NewLine);

However , only it can ring , theirs no voice . Working on it as soon as I get it will post.

one can refer my old question for better understanding How to make caller id in c#.net

相关问答

更多
  • 首先,你必须小心录制电话,因为有国家的法律要求。 以下是关于如何使用MediaRecorder录制音频的博客文章 。 我没有尝试录制电话,但MediaRecorder AudioSource中有一个选项用于: VOICE_CALL - 语音呼叫上行链路+下行音频源 VOICE_DOWNLINK - 语音呼叫下行(Rx)音频源 VOICE_UPLINK - 语音呼叫上行链路(Tx)音频源 只要音源选项有效,你应该很好。 First off, you have to be careful with record ...
  • 您可以发起呼叫 https://developer.apple.com/library/content/featuredarticles/iPhoneURLScheme_Reference/PhoneLinks/PhoneLinks.html 所以这可能会工作 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:12125551212"]]; You can initiate a call https://devel ...
  • 您将不得不捕获广播的消息: 在那里你可以决定你想要打开一个窗口的天气,并选择阻止广播进入其他接收器。 You will have to catch the broa ...
  • 看起来您想要传递SendDigits可选参数以及出站API调用。 有关更多信息,请在进行Twilio API调用时查看此可选参数列表 After thoroughly review the documentation, I found a noun for the verb that allows to provide sendDigits parameter. So my problem has been solved. Thanks to all of you for y ...
  • 对的,这是可能的。 使用以下步骤: 启动两个仿真器(例如,5556和5558) 在窗户上开始; 键入cmd; 并键入telnet localhost 5556,您将连接到端口5556上的仿真器 现在键入gsm call 5556 通过点击/绘制绿色电话到右侧来接收模拟器5556上的呼叫。 点击模拟器5556屏幕上带有+号的添加呼叫按钮。 在拨号盘上拨打号码5558并点击绿色电话图标。 你会听到它正在响起另一个模拟器5558。 在仿真器5558上,您将在一段时间后看到来电通知。 通过点击并接着点击电话图标和绿 ...
  • 尝试这个 call this number 看一下这个 在Android和iOS中通过PhoneGap拨打电话 try this call this number check this out Making a Phone Call from Within PhoneGap in Android and iOS
  • 这不能在iOS中完成,因为它是Apple强制执行的技术限制。 This cannot be done in iOS as its a technical restriction enforced by Apple.
  • 我设法提出了一个解决方案,以获得问题中描述的行为。 在我的问题中,我使用了相同的tel:// “link”概念。 我提出的解决方案: 创建一个URI 从应用程序启动它 然后设备处理打开URI; 询问必要时使用哪个应用程序 这就像一行一样简单: private async Task MakePhoneCall(string phoneNumber) { await Launcher.LaunchUriAsync(new Uri($"tel://{phoneNumber}")); } Launcher ...
  • Twilio开发者传道者在这里。 如果您正在寻找使用Twilio拨打电话,我建议您按照此快速入门指南使用C#拨打电话 。 它将带您了解基础知识。 为了更深入地了解一下,我将通过本教程来了解如何使用C#ASP.NET MVC构建一个单击调用系统 。 如果这有帮助,请告诉我。 I am able to solve the issue . As I already had hiro usb modem h50113 so i just used AT Command ATDT (Phone number) her ...
  • 我使用没有弹性中继的PHP帮助程序库来完成它。 在Twilio控制台的SIP域设置中,您可以设置语音配置的请求URL。 似乎当您尝试通过SIP拨打任何号码时,Twilio会请求此URL并使用请求POST所有呼叫信息变量。 其中一个变量是'Called',格式为sip:0123456789@yourdomain.sip.us1.twilio.com:5060其中0123456789是您拨打的号码 所以我们需要做的就是从字符串中删除数字,然后让Twilio拨打它。 很容易。 我创建了这个php文件,我在英国,因 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)