cursor

When Does Query Returns Null on Android?

♀尐吖头ヾ 提交于 2019-12-05 12:58:35
I don't seem to find any information on query, insert or any other SQL method returning null. But it does if error occurs. I just wonder whether cursor being null means an error occured or could it mean no rows were selected (for instance)? I don't know how I should treat it - as an error or something that may happen time to time. I don't believe you ever need to check if(cursor == null) {} . First If your query doesn't return any rows, you will receive an empty Cursor. The Cursor will not be null . There are many ways to check if a Cursor is empty: if(cursor.getCount == 0) {} if(!cursor

Change the color of the cursor of an EditText in Android across all the sdk

安稳与你 提交于 2019-12-05 12:45:24
问题 Want to change the android's edittext cursor color, that has to be worked on across all the devices 回答1: i had to use a drawable like this: mycursor.xml: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <size android:width="1dp" /> <solid android:color="@android:color/holo_blue_light"/> <!--make sure its a solid tag not stroke or it wont work --> </shape> in my edit text i set the cursor drawable attributes

7. SOFAJRaft源码分析—如何实现一个轻量级的对象池?

回眸只為那壹抹淺笑 提交于 2019-12-05 12:22:09
前言 我在看SOFAJRaft的源码的时候看到了使用了对象池的技术,看了一下感觉要吃透的话还是要新开一篇文章来讲,内容也比较充实,大家也可以学到之后运用到实际的项目中去。 这里我使用RecyclableByteBufferList来作为讲解的例子: RecyclableByteBufferList public final class RecyclableByteBufferList extends ArrayList<ByteBuffer> implements Recyclable { private transient final Recyclers.Handle handle; private static final Recyclers<RecyclableByteBufferList> recyclers = new Recyclers<RecyclableByteBufferList>(512) { @Override protected RecyclableByteBufferList newObject(final Handle handle) { return new RecyclableByteBufferList( handle); } }; //获取一个RecyclableByteBufferList实例 public static

Navigating the results of a stored procedure via a cursor using T-SQL

点点圈 提交于 2019-12-05 12:19:17
Due to a legacy report generation system, I need to use a cursor to traverse the result set from a stored procedure. The system generates report output by PRINTing data from each row in the result set. Refactoring the report system is way beyond scope for this problem. As far as I can tell, the DECLARE CURSOR syntax requires that its source be a SELECT clause. However, the query I need to use lives in a 1000+ line stored procedure that generates and executes dynamic sql. Does anyone know of a way to get the result set from a stored procedure into a cursor? I tried the obvious: Declare Cursor c

java源码 -- AbstractList

倾然丶 夕夏残阳落幕 提交于 2019-12-05 11:24:06
AbstractList    AbstractList是实现List接口的抽象类 ,AbstractList抽象类与List接口的关系类似于AbstractCollection抽象类与Collection接口的关系。   AbstractList与AbstractCollection一样,也是通过提供一些方法的默认实现,简化我们编写List接口的列表类所需付出的努力。 实现列表类的需要记住:   1)要想实现一个不可修改的集合,只需要继承这个类,并且实现get(int)、size()方法;   2)要想实现一个可以修改的集合,还必须重写set(int, E)方法,该方法默认抛出一个异常。如果集合是可动态调整大小的,还必须重写add(int, E),remove(int)方法。 方法   public boolean add(E e){} public boolean add(E e) { add(size(), e); //通过调用add(int, E)方法进行添加 return true; } //以下方法没有具体的实现,调用它时,抛出异常。 public void add (int index, E element){ throw new UnsupportedOperationException (); } public E set (int index, E

How to pass Cursor Object to next Activity using Intents

情到浓时终转凉″ 提交于 2019-12-05 10:45:42
I'm familiar with how to pass Raw Data(String, int, boolean etc) from one Activity to another Activity. But in my application, I want to pass a Cursor object to next Activity. I'm extending my class from the Activity Class. Though I have looked at this post . but it provides cotradictory solutions. However, as described by one of the users, one should extend Application class to pass cursor data. But I want to extend Activity class. So is there any way to pass Cursor data from an Activity to another Activity. Note- If it helps, the fact why I want to use the cursor is, I'm querying data for a

Django Backend-neutral DictCursor

帅比萌擦擦* 提交于 2019-12-05 10:44:16
Is there any way to get a backend-neutral dictionary cursor in Django? This would be a cursor that is a dict rather than a tuple. I am forced to use Oracle for the school project I'm working on. in Python's MySQLDb module it's called a DictCursor. With WoLpH's inspiring suggestion I know I am very close.. def dict_cursor(cursor): for row in cursor: yield dict(zip(cursor.description, row)) Iterating and printing each row cursor used to result in: (482072, 602592, 1) (656680, 820855, 2) (574968, 718712, 4) (557532, 696918, 3)) But with dict_cursor I get: {('NET_SPENT', <type 'cx_Oracle.NUMBER'>,

get contacts performance issue

≡放荡痞女 提交于 2019-12-05 10:36:17
I am trying to get contacts of the android device. I found a great sample code here However, when trying to populate a ListActivity with ArrayAdapter that is using that code it is taking a lot of time - almost 4 seconds on galaxy s2 and much more on older devices. I need to improve that performance. What I thought is to implements Cursor that will hold more than one dimension Cursor , and use SimpleCursorAdapter as the list adapter. I see few problems with this approach: I don't know how to get item at specific position. each cursor has different columns. Is there a better/easier way to do

HTML Textarea - cursor starting in center of textarea rather than top

邮差的信 提交于 2019-12-05 09:09:53
I have an HTML template and CSS that renders a textarea field, however when clicking in the field, the cursor starts from half way down the text area, not from the top left as I would expect. This does not occur in IE, but does in Chrome and FF. I also get a list of previous values entered listed below, suggesting that the textbox styles are being applied. Can anyone advise on which CSS proprties I should be looking to modify? Here is the HTML: <input id="description" class="textarea" type="textarea" name="description" cols="70" rows="50"> Here are the properties being assigned to the text

SQLHelper ------ python实现

白昼怎懂夜的黑 提交于 2019-12-05 08:34:34
SQLHelper ------ python实现 1.第一种: import pymysql import threading from DBUtils.PooledDB import PooledDB class SqlHelper(object): def __init__(self): self.pool = PooledDB( creator=pymysql, # 使用链接数据库的模块 maxconnections=6, # 连接池允许的最大连接数,0和None表示不限制连接数 mincached=2, # 初始化时,链接池中至少创建的链接,0表示不创建 blocking=True, # 连接池中如果没有可用连接后,是否阻塞等待。True,等待;False,不等待然后报错 ping=0, # ping MySQL服务端,检查是否服务可用。# 如:0 = None = never, 1 = default = whenever it is requested, 2 = when a cursor is created, 4 = when a query is executed, 7 = always host='127.0.0.1', port=3306, user='root', password='000000', database='flask_day1',