ALT Linux Community general discussions
 help / color / mirror / Atom feed
* Re: [Comm] Java + Postgresql
  @ 2003-06-18  5:31 ` Eugene
  0 siblings, 0 replies; only message in thread
From: Eugene @ 2003-06-18  5:31 UTC (permalink / raw)
  To: "Михаил
	Дворников"

Hello Михаил,

Wednesday, June 18, 2003, 8:56:57 AM, you wrote:

МД> Здравствуйте!
МД> Дистрибутив Master 2.2.
МД> Поставил Java, Postgresql (в том числе postgresql-jdbc).
МД> Тестовая программа:
МД> import java.sql.*;

МД> class Msql {
МД>     public static void main(String args[]){
try {
МД>         Class.forName("org.postgresql.Driver");
МД>         Connection db = DriverManager.getConnection("jdbc:postgresql:test", "postgres", "");
//на всякий пожарный - "jdbc:postgresql:test", "postgres", ""
//на счет строчкий этой... глянь любой пример, как правльно пишется
МД>         db.close();
} catch (Exception e)
{
//тут рапортуем об ошибке
//Эксепшены можно и по именам отлавливать и обрабатывать - дело
//хозяйское..:)
}

МД>     }
МД> }

МД> К базе test через psql подключался нормально.


МД> Выдает ошибки:
МД> $javac Msql.java

МД> Msql.java:5: unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown
МД>         Class.forName("org.postgresql.Driver");
МД>              ^
Можем не найти класс -  получим эксэпшн
МД> Msql.java:6: unreported exception java.sql.SQLException; must be caught or declared to be thrown
МД>         Connection db = DriverManager.getConnection("jdbc:postgresql:test", "postgres", "");
МД>                                      ^
МД> Msql.java:7: unreported exception java.sql.SQLException; must be caught or declared to be thrown
МД>         db.close(); 
МД>           ^
Могут возникнуть проблеммы с БД -  получим эксэпшн
МД> 3 errors

Ну он же "русским" я зыком просит, чтобы ты вставил try-catch..;)

Всего наилучшего.
Удачи.


-- 
Best regards,
 Eugene                            mailto:team_pro@gala.net


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-06-18  5:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-18  5:31 ` [Comm] Java + Postgresql Eugene

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git