我写了这个小函数来填充下拉列表,其中包含来自服务器的数据.
function fillDropDown(url, dropdown) {
$.ajax({
url: url,
dataType: "json"
}).done(function (data) {
// Clear drop down list
$(dropdown).find("option").remove(); <<<<<< Issue here
// Fill drop down list with new data
$(data).each(function () {
// Create option
var $option = $("<option />");
// Add value and text to option
$option.attr("value", this.value).text(this.text);
// Add option to drop down list
$(dropdown).append($option);
});
});
}
Run Code Online (Sandbox Code Playgroud)
然后我可以这样调用函数:
fillDropDown("/someurl/getdata", $("#dropdownbox1"))
Run Code Online (Sandbox Code Playgroud)
一切都工作得很好,除了我从下拉列表中清除旧数据的一行.我究竟做错了什么?
任何可能有助于改进此代码的提示也受到高度赞赏.
我想有一个自定义ListView,其中每行包含一个EditText字段,可以由用户编辑.但是,当我点击其中一个EditTexts时,我失去了焦点,并且无法在那里键入文本(我想是因为其他行被重绘并获得焦点).我能做什么?
我看到了这段代码
const volatile int * volatile * const X;
Run Code Online (Sandbox Code Playgroud)
但我无法理解第二个*意味着什么.
我明白那个
const volatile int*volatile const X;
表示易失性const数据的volatile整数指针.
如何在Linux中运行程序并了解其PID?
如果我有几个shell相互运行,它们都会有单独的PID吗?
我使用 SocketChannel 为 Android 编写了一个聊天应用程序。它与服务器成功连接并且所有功能都正常工作。但是在我登录后很长时间(大约 2-3 小时)后,我尝试再次发送聊天消息,但失败了。在日志文件中,SocketChannel,选择器仍然打开并连接到服务器,消息已经写入成功。有什么问题?我错过了什么?
在此先感谢您的帮助。
我们正在开发Java SE应用程序,而我正在使用Hibernate与数据库进行通信。我的数据库是Oracle 11g Express Edition。到目前为止,我尚未在应用程序中使用连接池。但是我以前使用过c3p0连接池,但是我从未真正了解过它。
在Java SE应用程序中使用c3p0的优缺点是什么?我了解Java EE应用程序有用,但是Java SE吗?
这是我的休眠配置。
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
<property name="hibernate.connection.username">EP</property>
<property name="hibernate.connection.password">123</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.default_schema">EP</property>
<property name="show_sql">true</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<mapping class="app.model.User"></mapping>
</session-factory>
</hibernate-configuration>
Run Code Online (Sandbox Code Playgroud) 得到 java.sql.SQLException
java.sql.SQLException: General error
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6986)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3110)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:253)
at com.test.Temp.main(Temp.java:29)
Run Code Online (Sandbox Code Playgroud)
我正在使用以下代码
Connection con=null;
ResultSet rs=null;
Statement stmt=null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:locator","locator","locator");
stmt=con.createStatement();
System.out.println("Before query");
String query=null;
query="select * from user_location_table";
System.out.println("after query12");
rs=stmt.executeQuery(query);
//perform certain operation....
rs.close();
stmt.close();
con.close();
} catch(Exception e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
在 处抛出异常stmt.executeQuery(query)
。
user_location_table 包含以下字段
user_id:number not null,
latitude:number,
longitude:number,
update_time:timestamp(6)
Run Code Online (Sandbox Code Playgroud)
提前致谢