适用于Oracle 10g的Android ODBC连接 [英] android odbc connection for oracle 10g
问题描述
可能重复:结果
Android的JDBC ODBC连接
块引用>我使用Oracle数据库11g之前,我的Android应用程序,并成功地存储的值。不幸的是我的Oracle数据库11g无法打开,由于一些问题。我卸载的Oracle 11g并安装Oracle数据库10g版本。现在我编译甲骨文计划并关闭仿真器和开放的表中的值不能保存。我不知道这个问题是如何发生的。在这里,在我的code,我把端口号1521和SID是ORCL和表名是样本。请给出一个解决方案,并在端口号和SID的任何更改。在此先感谢
包com.search; 进口java.sql.Connection中;
进口java.sql.DriverManager中;
。进口的java.sql preparedStatement; 进口android.app.Activity;
进口android.os.Bundle; 公共类OraclesearchActivity延伸活动{
/ **当第一次创建活动调用。 * /
@覆盖
公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.main);
字符串=karthick;
字符串B =维杰;
字符串C =VEL;
尝试
{
DriverManager.registerDriver(新oracle.jdbc.driver.OracleDriver()); 连接CON =的DriverManager.getConnection(JDBC:神谕:薄:// 192.168.1.2:1521:ORCL,系统,字); 。preparedStatement PST = CON prepareStatement(插入样品(第一,中间,最后)的值(,)???);
pst.setString(1,一);
pst.setString(2,B);
pst.setString(3,C);
pst.executeUpdate(); }
赶上(例外五)
{
的System.out.println(异常:+ E);
}
}
}
解决方案也许不是您所渴望的,但我会认真质疑有一个移动设备的智慧的答案直接连接到Oracle或任何DBMS。
相反,考虑把一个REST或SOAP服务DBMS的前面,让您的移动应用程序连接到。
一些好处包括:
- 当你的DBMS或数据库管理系统的驱动程序版本改变,你只需要
更新您的服务...不是潜在的大量的移动设备。- 您不要有哪些潜在的丢失或其他移动设备上的凭据您的DBMS在恶劣的环境中结束了
如果有人可以尝试暴力破解你已尝试任何方式
确保凭据。- 您的服务可以支持许多不同类型的客户端/移动设备,而无需担心找不到一个oracle驱动程序
该设备,说的iOS,例如。- 您可以更优雅地通过服务处理服务中断/计划的停机时间...通过宣布不可用或替代方案
服务响应,而不是仅仅不能够得到
连接这可能是由坏区分网络
连接。- 您将有丰富的选项,充实各种缓存选项,验证服务,并应用更细粒度或
可能比你想实现什么情况下特定的授权
在oracle中。 -也许你真的有一些硬性要求直接连接,但我认为这将是一个难得的和非常具体的要求。在更普遍的做法似乎是缓冲带,为您提供了更多的灵活性服务层的连接,恕我直言。
祝你好运。
Possible Duplicate:
android jdbc odbc connectionbefore i used oracle database 11g for my android application and successfully stored values. Unfortunately my oracle database 11g could not open due to some problem . I uninstalled oracle 11g and installed oracle database 10g edition. now i compiled program and close emulator and open table in oracle the values could not be stored . I dont know how this problem occur. Here in my code i put port number 1521 and sid is 'orcl' and table name is 'sample'. Pls give one solution and any changes in port number and sid . Thanks in advance
package com.search; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import android.app.Activity; import android.os.Bundle; public class OraclesearchActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String a="karthick"; String b="vijay"; String c="vel"; try { DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.2:1521:orcl","system","words"); PreparedStatement pst=con.prepareStatement("insert into sample(first,middle,last)values(?,?,?)"); pst.setString(1,a); pst.setString(2,b); pst.setString(3,c); pst.executeUpdate(); } catch(Exception e) { System.out.println("Exception:"+e); } } }
解决方案Probably not the answer youre looking for but I would seriously question the wisdom of having a mobile device connect directly to oracle, or any dbms.
Instead, consider putting a REST or SOAP service in front of your dbms and let your mobile apps connect to that.
Some of the benefits include:
- When your dbms or dbms drivers change versions, you only have to update your service...not potentially lots of mobile devices.
- You dont have the credentials to your dbms on a mobile device which potentially gets lost or otherwise ends up in hostile environment where someone can try to brute force whatever way youve attempted to secure the credentials.
- Your service can support lots of different kinds of clients/mobile devices without having to worry about finding an oracle driver for that device, say iOS, for example.
- You can more gracefully handle service outage / planned downtime via the service...announcing unavailability or alternatives via service responses, rather than just not being able to get a connection which could be indistinguishable from bad network connections.
- You'll have a wealth of options for augmenting the service with various caching options, validations, and applying finer grained or context specific authorization than what you might want to implement in oracle. -
Perhaps you really have some hard requirement to connect directly but I think that would be a rare and very specific requirement. The much more common practice seems to be to buffer the connection with a service layer that gives you much more flexibility, IMHO.
Good luck.
这篇关于适用于Oracle 10g的Android ODBC连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!