В чем разница между JDK и JRE?

В качестве драйвера db существует также oursql . Некоторые из причин, перечисленных в этой ссылке, говорят о том, почему oursql лучше:

  • oursql имеет реальную параметризацию, посылая SQL и данные в MySQL полностью отдельно.
  • oursql позволяет передавать текстовые или двоичные данные в базу данных и выводиться из базы данных, а не требовать, чтобы все было буферизировано в клиенте.
  • oursql может лениво вставлять строки и извлекать строки лениво.
  • По умолчанию ussql поддерживает Unicode.
  • oursql поддерживает python с 2.4 по 2.7 без каких-либо предупреждений об отказе от версии 2.6+ (см. PEP 218) и без полного отказа от 2.7 (см. PEP 328) .
  • oursql запускается изначально на python 3.x.
blockquote>

Итак, как подключиться к mysql с oursql?

Очень похоже to mysqldb:

import oursql

db_connection = oursql.connect(host='127.0.0.1',user='foo',passwd='foobar',db='db_name')
cur=db_connection.cursor()
cur.execute("SELECT * FROM `tbl_name`")
for row in cur.fetchall():
    print row[0]

Учебник в документации довольно приличный.

И, конечно же, для ORM SQLAlchemy - хороший выбор, как уже упоминалось в других ответах.

815
задан assylias 28 August 2012 в 15:09
поделиться

2 ответа

The JRE is the Java Runtime Environment. It is a package of everything necessary to run a compiled Java program, including the Java Virtual Machine (JVM), the Java Class Library, the java command, and other infrastructure. However, it cannot be used to create new programs.

The JDK is the Java Development Kit, the full-featured SDK for Java. It has everything the JRE has, but also the compiler (javac) and tools (like javadoc and jdb). It is capable of creating and compiling programs.

Usually, if you only care about running Java programs on computer you will only install the JRE. It's all you need. On the other hand, if you are planning to do some Java programming, you need to install the JDK instead.

Sometimes, even if you are not planning to do any Java development on a computer, you still need the JDK installed. For example, if you are deploying a web application with JSP, you are technically just running Java programs inside the application server. Why would you need the JDK then? Because the application server will convert JSP into Java servlets and needs to use the JDK to compile the servlets. I am sure there are be more examples.

1136
ответ дан 22 November 2019 в 21:09
поделиться

The answer above (by Pablo) is very right. This is just additional information.

The JRE is, as the name implies, an environment. It's basically a bunch of directories with Java-related files, to wit:

  • bin/ contains Java's executable programs. The most important is java (and for Windows, javaw as well), which launches the JVM. There are some other utilities here as well, such as keytool and policytool.
  • conf/ holds user-editable configuration files for Java experts to play with.
  • lib/ has a large number of supporting files: some .jars, configuration files, property files, fonts, translations, certs, etc. – all the "trimmings" of Java. The most important is modules, a file that contains the .class files of the Java standard library.
  • At a certain level, the Java standard library needs to call into native code. For this purpose, the JRE contains some .dll (Windows) or .dylib (macOS) or .so (Linux) files under bin/ or lib/ with supporting, system-specific native binary code.

The JDK is also a set of directories. It is a superset of the JRE, with some additions:

  • bin/ has been enlarged with development tools. The most important of them is javac; others include jar, javadoc and jshell.
  • jmods/, which holds JMOD files for the standard library, has been added. These files allow the standard library to be used with jlink.
131
ответ дан 22 November 2019 в 21:09
поделиться
Другие вопросы по тегам:

Похожие вопросы: