首页 \ 问答 \ 无法通过rails连接到oracle(cannot connect to oracle through rails)

无法通过rails连接到oracle(cannot connect to oracle through rails)

尝试通过Ruby On Rails连接到oracle时遇到问题( ruby -r oci8 -e "OCI8.new('hr', 'password').exec('SELECT * FROM jobs ORDER BY 1') {|r| puts r.join}" )如下:

C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_re
quire.rb:46:in `require': incompatible library version - C:/RailsInstaller/Ruby1
.9.3/lib/ruby/site_ruby/1.9.1/i386-msvcrt/oci8lib.so (LoadError)
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:46:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/oci8.rb:20:in
`<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:46:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:46:in `require'

这是我正在使用的:

 1. ruby1.9.3p125 (2012-02-16) [i386-mingw32]
 2. Rails 3.2.1
 3. gem 2.0.3
 4. Windows 7
 5. Oracle 10g Express Edition

有谁知道如何解决上述问题?

提前致谢。


I got problem when trying to connect to oracle through Ruby On Rails ( ruby -r oci8 -e "OCI8.new('hr', 'password').exec('SELECT * FROM jobs ORDER BY 1') {|r| puts r.join}" ) as following:

C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_re
quire.rb:46:in `require': incompatible library version - C:/RailsInstaller/Ruby1
.9.3/lib/ruby/site_ruby/1.9.1/i386-msvcrt/oci8lib.so (LoadError)
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:46:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/oci8.rb:20:in
`<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:46:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:46:in `require'

Here is what I am using:

 1. ruby1.9.3p125 (2012-02-16) [i386-mingw32]
 2. Rails 3.2.1
 3. gem 2.0.3
 4. Windows 7
 5. Oracle 10g Express Edition

Anyone know how to solve the above problem?

Thanks in advance.


原文:https://stackoverflow.com/questions/15518366
更新时间:2022-04-09 14:04

最满意答案

public List<Appo> getAllData() {
    List<Appo> appos = new ArrayList<Appo>();
    // Select All Query
    String selectQuery = "SELECT  * FROM " + APPOINTMENT_TABLE_NAME;

    SQLiteDatabase db = this.getWritableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);

    // looping through all rows and adding to list
    if (cursor.moveToFirst()) {
        do {
            Appo appo = new Appo();
            appo.setTital(cursor.getString(0));
            appo.setTime(cursor.getString(1));
            appo.setDetails(cursor.getString(2));
            appo.setday(cursor.getString(3));

            //Adding contact to list
            appos.add(appo);
        } while (cursor.moveToNext());
    }
    // return all list
    return appos;
}

有关更多信息,请查看Android SQLite数据库


public List<Appo> getAllData() {
    List<Appo> appos = new ArrayList<Appo>();
    // Select All Query
    String selectQuery = "SELECT  * FROM " + APPOINTMENT_TABLE_NAME;

    SQLiteDatabase db = this.getWritableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);

    // looping through all rows and adding to list
    if (cursor.moveToFirst()) {
        do {
            Appo appo = new Appo();
            appo.setTital(cursor.getString(0));
            appo.setTime(cursor.getString(1));
            appo.setDetails(cursor.getString(2));
            appo.setday(cursor.getString(3));

            //Adding contact to list
            appos.add(appo);
        } while (cursor.moveToNext());
    }
    // return all list
    return appos;
}

For more information check Android SQLite Database

相关问答

更多
  • 这是我如何打开我的数据库。 我很长一段时间没有做SQLite,除了提供我在自己的应用程序中使用的代码之外,我无法给你很多帮助。 这是我在我的应用程序中使用的一个类。 static sqlite3 *database; static sqlite3_stmt *enableForeignKey; @implementation DBAdapter + (sqlite3 *)sharedInstance { if (database == NULL) { sqlite3 *newD ...
  • 使用此代码并检查数据库是否已连接并正确打开,然后再从中获取数据。 希望这会有所帮助。 -(void)readDatabase { // Set path NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);//(customize the path based on ur database location) ...
  • 在主活动中添加此代码并重新启动您的活动。 确保已调用此代码并设置正确的SD卡路径。 在Windows上安装sqlite manager工具并查看您的数据。 try { String inFileName = "//data/data/com.needzapp.debug/databases/your_db_name"; File dbFile = new File(inFileName); FileInputStream fis ...
  • 作为pysqlite的作者,我很确定没有人将pysqlite 1.x移植到Python 3。 理所当然的唯一解决方案是theomega建议的那个。 如果你需要的只是从Python访问数据以便将它们导入其他地方,但是不能进行sqlite2 dump / sqlite3恢复舞蹈,有一个选项,但是不方便:使用builtin ctypes模块从中访问必要的函数SQLite 2 DLL。 然后,您将自己实现一个最小版本的pysqlite,它只包含您真正需要的内容。 As the pysqlite author I a ...
  • 使用c无法将数组分配给另一个数组,您必须将源数组内容复制到目标数组,例如使用strcpy unsigned char *value = sqlite3_column_text(SQL,2); if ((value != NULL) && (strlen(value) < sizeof(Register[i].InstrumentType))) { strcpy(Register[i].InstrumentType, value); } 在您的特定情况下,您还可以使用指针来重构您的结构 ...
  • 首先,对于一个Task,你只需要产生返回promise的东西,因此异步运行。 没有必要yield iDs.push(row[i].getResultByIndex(0)); ,因为push操作将同步返回数组的新长度。 尽管如此,这对代码本身来说应该不是什么大问题。 你真的需要ids是全球性的吗? 也许您可以重构代码,这样您就不需要在全局范围内保存它们。 如果这不是一个选项,则必须阻止所有将访问id的操作,直到SQL调用完成。 你可以依靠Task.spawn()本身也会返回一个promise的事实来做到这一点 ...
  • 如果您真的对学习如何使用SQLite管理iPhone应用程序中的数据感兴趣,我建议您完成以下教程,因为它是一个非常好的介绍: 使用iPhone编程教程创造-A-待办事项列表- - sqlite的部分-1 本教程使用SQLite处理iPhone应用程序中的选择,更新,插入和删除数据。 If you're really interested in learning how to use SQLite to manage data in an iPhone app, I would recommend you t ...
  • 我回答自己:不,似乎不可能。 read_uncommitted隔离模式需要启用共享缓存,目前只能用于生活在同一进程中的不同线程。 这似乎是研究这个的最佳场所: http : //www.sqlite.org/sharedcache.html 。 I answer to myself: no, it seems it is not possible. The read_uncommitted isolation mode requires to enable the shared cache, which i ...
  • 实际问题与游标无关,游标读取下一行,但在第一次写入数据后关闭文档。 尝试关闭for循环外的文档对象。 把这条线放在for loop的外面 doc.close(); Actual Problem is not related to a cursor, cursor read the next line but you close the document after first data write. try to close the document object outside of for loop ...
  • public List getAllData() { List appos = new ArrayList(); // Select All Query String selectQuery = "SELECT * FROM " + APPOINTMENT_TABLE_NAME; SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery ...

相关文章

更多

最新问答

更多
  • 您如何使用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)